forked from ddliu/go-httpclient
/
default_client.go
50 lines (45 loc) · 1.64 KB
/
default_client.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
// Copyright 2014-2015 Liu Dong <ddliuhb@gmail.com>.
// Licensed under the MIT license.
// Powerful and easy to use http client
package httpclient
import (
"io"
"net/http"
)
// The default client for convenience
var defaultClient *HttpClient
var Defaults func(Map) *HttpClient
var Begin func() *HttpClient
var Do func(string, string, map[string]string, io.Reader) (*Response, error)
var Get func(string, map[string]string) (*Response, error)
var Delete func(string, map[string]string) (*Response, error)
var Head func(string, map[string]string) (*Response, error)
var Post func(string, map[string]string) (*Response, error)
var PostMultipart func(string, map[string]string) (*Response, error)
var WithOption func(int, interface{}) *HttpClient
var WithOptions func(Map) *HttpClient
var WithHeader func(string, string) *HttpClient
var WithHeaders func(map[string]string) *HttpClient
var WithCookie func(...*http.Cookie) *HttpClient
var Cookies func(string) []*http.Cookie
var CookieValues func(string) map[string]string
var CookieValue func(string, string) string
func init() {
defaultClient = NewHttpClient()
Defaults = defaultClient.Defaults
Begin = defaultClient.Begin
Do = defaultClient.Do
Get = defaultClient.Get
Delete = defaultClient.Delete
Head = defaultClient.Head
Post = defaultClient.Post
PostMultipart = defaultClient.PostMultipart
WithOption = defaultClient.WithOption
WithOptions = defaultClient.WithOptions
WithHeader = defaultClient.WithHeader
WithHeaders = defaultClient.WithHeaders
WithCookie = defaultClient.WithCookie
Cookies = defaultClient.Cookies
CookieValues = defaultClient.CookieValues
CookieValue = defaultClient.CookieValue
}