Documentation ¶
Index ¶
- Constants
- Variables
- func AssertEqual(t *testing.T, received interface{}, expected interface{})
- func Decode(contentType string, val interface{}) ([]byte, error)
- func Encode(contentType string, data []byte, val interface{}) error
- func UrlFormat(rawUrl string, pathParam map[string]interface{}) string
- func UrlJoin(baseUrl string, segments ...string) (string, error)
- type After
- type BasicAuth
- type Before
- type ConditionBind
- type Encoder
- type JSONEncoder
- type Request
- func (request *Request) AddCookies(cookies ...*http.Cookie) *Request
- func (request *Request) End() *Response
- func (request *Request) Form(form interface{}) *Request
- func (request *Request) Param(param map[string]interface{}) *Request
- func (request *Request) Query(query interface{}) *Request
- func (request *Request) RawRequest() (*http.Request, error)
- func (request *Request) Send(data interface{}) *Request
- func (request *Request) Set(key, value interface{}) *Request
- func (request *Request) SetBasicAuth(auth BasicAuth) *Request
- func (request *Request) SetHeader(key, value string) *Request
- func (request *Request) Type(typ string) *Request
- func (request *Request) WithCTX(ctx context.Context) *Request
- type Response
- func (resp *Response) BindBody(data interface{}) *Response
- func (resp *Response) BindBytes(b *[]byte) *Response
- func (resp *Response) BindError(err *error) *Response
- func (resp *Response) BindHeader(header *http.Header) *Response
- func (resp *Response) BindIsCancel(ok *bool) *Response
- func (resp *Response) BindIsTimeout(ok *bool) *Response
- func (resp *Response) BindStatus(status *string) *Response
- func (resp *Response) BindStatusCode(code *int) *Response
- func (resp *Response) Body() io.ReadCloser
- func (resp *Response) Bytes() []byte
- func (resp *Response) ConditionBindBody(check func(interface{}) bool, data ...interface{}) *Response
- func (resp *Response) Error() error
- func (resp *Response) Header() http.Header
- func (resp *Response) IsCancel() bool
- func (resp *Response) IsTimeout() bool
- func (resp *Response) Status() string
- func (resp *Response) StatusCode() int
- type TraceInfo
- type WuKong
- func (wk *WuKong) Delete(path string) *Request
- func (wk *WuKong) Get(path string) *Request
- func (wk *WuKong) Head(path string) *Request
- func (wk *WuKong) Options(path string) *Request
- func (wk *WuKong) Patch(path string) *Request
- func (wk *WuKong) Post(path string) *Request
- func (wk *WuKong) Put(path string) *Request
- func (wk *WuKong) SetBasicAuth(auth BasicAuth) *WuKong
- func (wk *WuKong) SetTransport(transport *http.Transport) *WuKong
- func (wk *WuKong) Timeout(t time.Duration) *WuKong
- func (wk *WuKong) Trace(path string) *Request
- func (wk *WuKong) UseAfter(fns ...After) *WuKong
- func (wk *WuKong) UseBefore(fns ...Before) *WuKong
- type XMLEncoder
Constants ¶
View Source
const ( MimeTypeJSON = "application/json" MimeTypeXML = "application/xml" MimeTypeFormData = "application/x-www-form-urlencoded" MimeTypeUrlencoded = "application/x-www-form-urlencoded" MimeTypeHTML = "text/html" MimeTypeText = "text/plain" MimeTypeMultipart = "multipart/form-data" )
Variables ¶
View Source
var ( DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, } )
Functions ¶
func AssertEqual ¶
Types ¶
type ConditionBind ¶
type ConditionBind struct { Data interface{} Check func() bool }
type JSONEncoder ¶
type JSONEncoder struct{}
func (*JSONEncoder) Decode ¶
func (c *JSONEncoder) Decode(v interface{}) ([]byte, error)
func (*JSONEncoder) Encode ¶
func (c *JSONEncoder) Encode(data []byte, val interface{}) error
func (*JSONEncoder) MimeType ¶
func (c *JSONEncoder) MimeType() string
type Request ¶
type Request struct { TraceInfo TraceInfo Context context.Context BasicAuth BasicAuth Error error Method string BaseUrl string Url string ContentType string Header http.Header QueryData url.Values FormData url.Values ParamData map[string]interface{} BodyData interface{} Cookies []*http.Cookie // contains filtered or unexported fields }
func NewRequest ¶
func (*Request) Param ¶
Param Method sets multiple URL path key-value pairs.
For example: http://example.com/users/:uid
client.Get("http://example.com/users/:uid").Param(map[string]interface{}{"uid": "123"}).End()
request target Url will be replace to `http://example.com/users/123`
func (*Request) SetBasicAuth ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) BindIsCancel ¶
func (*Response) BindIsTimeout ¶
func (*Response) BindStatus ¶
func (*Response) BindStatusCode ¶
func (*Response) Body ¶
func (resp *Response) Body() io.ReadCloser
func (*Response) ConditionBindBody ¶
func (*Response) StatusCode ¶
type TraceInfo ¶
type TraceInfo struct { HostPort string GotConnInfo httptrace.GotConnInfo DNSStartInfo httptrace.DNSStartInfo DNSDoneInfo httptrace.DNSDoneInfo ConnectNetwork string ConnectAddr string ConnectError error TLSConnectionState tls.ConnectionState TLSError error ElapsedTime time.Duration GetConnAt time.Time GotConnAt time.Time GetConnElapsed time.Duration DNSStartAt time.Time DNSDoneAt time.Time DNSLookupElapsed time.Duration ConnectStartAt time.Time ConnectDoneAt time.Time ConnectElapsed time.Duration TLSHandshakeStartAt time.Time TLSHandshakeDoneAt time.Time TLSHandshakeElapsed time.Duration GotFirstResponseByteAt time.Time }
type WuKong ¶
type WuKong struct {
// contains filtered or unexported fields
}
func (*WuKong) SetBasicAuth ¶
type XMLEncoder ¶
type XMLEncoder struct{}
func (*XMLEncoder) Decode ¶
func (c *XMLEncoder) Decode(v interface{}) ([]byte, error)
func (*XMLEncoder) Encode ¶
func (c *XMLEncoder) Encode(data []byte, val interface{}) error
func (*XMLEncoder) MimeType ¶
func (c *XMLEncoder) MimeType() string
Click to show internal directories.
Click to hide internal directories.