-
Notifications
You must be signed in to change notification settings - Fork 0
/
drill.go
60 lines (51 loc) · 1001 Bytes
/
drill.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package drill
import (
"net/http"
"net/url"
)
type drill struct {
url *url.URL
method string
}
func new(urls string, mthd string) *drill {
parseurls, err := url.Parse(urls)
if err != nil {
panic(err)
}
return &drill{
url: parseurls,
method: mthd,
}
}
func Get(url string) {
client := new(url, "GET")
http.Get(client.url.String())
}
func Post(url string) {
client := new(url, "POST")
http.Post(client.url.String(), "", nil)
}
func Put(url string) {
client := new(url, "PUT")
r, err := http.NewRequest(client.method, client.url.String(), nil)
if err != nil {
panic(err)
}
http.DefaultClient.Do(r)
}
func Delete(url string) {
client := new(url, "DELETE")
r, err := http.NewRequest(client.method, client.url.String(), nil)
if err != nil {
panic(err)
}
http.DefaultClient.Do(r)
}
func Head(url string) {
client := new(url, "HEAD")
r, err := http.NewRequest(client.method, client.url.String(), nil)
if err != nil {
panic(err)
}
http.DefaultClient.Do(r)
}