-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontentType.go
More file actions
43 lines (35 loc) · 1.02 KB
/
Copy pathcontentType.go
File metadata and controls
43 lines (35 loc) · 1.02 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
43
package grequest
const (
contentType = "Content-Type"
formUrlencoded = "application/x-www-form-urlencoded"
multipartFormData = "multipart/form-data"
)
type ContentType struct {
Client *HTTPClient
}
func (c *HTTPClient) ContentType() *ContentType {
return &ContentType{Client: c}
}
// Gets http client object
func (c *ContentType) client() *HTTPClient {
return c.Client
}
// Sets content type in request header
func (c *ContentType) Set(value string) *HTTPClient {
c.client().Header().Set(contentType, value)
return c.client()
}
// Sets content type in request header
func (c *ContentType) SetFormUrlencoded() *HTTPClient {
c.client().Header().Set(contentType, formUrlencoded)
return c.client()
}
// Sets content type in request header
func (c *ContentType) SetMultipartFormData() *HTTPClient {
c.client().Header().Set(contentType, multipartFormData)
return c.client()
}
// Gets content type fron response headers and return as string
func (c *ContentType) Get() string {
return c.client().Header().Get(contentType)
}