-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods.go
More file actions
42 lines (33 loc) · 1.17 KB
/
methods.go
File metadata and controls
42 lines (33 loc) · 1.17 KB
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
package requests
import (
"errors"
)
// Implementations of the seven HTTP methods
func (this *session) Method(method string, urlPath string) (Request, error) {
if method != "GET" && method != "POST" && method != "PUT" && method != "DELETE" &&
method != "HEAD" && method != "OPTIONS" && method != "PATCH" {
return nil, errors.New("method not supported")
}
return newRequest(method, urlPath, this)
}
func (this *session) Get(urlPath string) (Request, error) {
return newRequest("GET", urlPath, this)
}
func (this *session) Post(urlPath string) (Request, error) {
return newRequest("POST", urlPath, this)
}
func (this *session) Put(urlPath string) (Request, error) {
return newRequest("PUT", urlPath, this)
}
func (this *session) Delete(urlPath string) (Request, error) {
return newRequest("DELETE", urlPath, this)
}
func (this *session) Head(urlPath string) (Request, error) {
return newRequest("HEAD", urlPath, this)
}
func (this *session) Options(urlPath string) (Request, error) {
return newRequest("OPTIONS", urlPath, this)
}
func (this *session) Patch(urlPath string) (Request, error) {
return newRequest("TRACE", urlPath, this)
}