Documentation ¶
Index ¶
- Constants
- func Decode(contentType string, val interface{}) ([]byte, error)
- func Encode(contentType string, data []byte, val interface{}) error
- type After
- type BasicAuth
- type Before
- type Encoder
- type JSONEncoder
- type LoggerLevel
- 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) Logger(level LoggerLevel) *Request
- func (request *Request) Metric(enable bool) *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) IgnoreEncodeErr() *Response
- 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) Client() *http.Client
- func (wk *WuKong) Delete(path string) *Request
- func (wk *WuKong) Get(path string) *Request
- func (wk *WuKong) Head(path string) *Request
- func (wk *WuKong) Logger(lv LoggerLevel) *WuKong
- func (wk *WuKong) Metric(enable bool) *WuKong
- 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) SetHeader(header map[string]string) *WuKong
- func (wk *WuKong) SetQuery(query map[string]string) *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" MimeTypeJSON1 = "text/json" MimeTypeJSON2 = "json" MimeTypeXML = "application/xml" MimeTypeXML1 = "text/xml" MimeTypeXML2 = "/xml" MimeTypeFormData = "application/x-www-form-urlencoded" MimeTypeUrlencoded = "application/x-www-form-urlencoded" MimeTypeHTML = "text/html" MimeTypeText = "text/plain" MimeTypeMultipart = "multipart/form-data" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 LoggerLevel ¶ added in v1.0.0
type LoggerLevel int
const ( LoggerDisable LoggerLevel = 1 << iota LoggerRequest LoggerResponse )
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) Logger ¶ added in v1.0.0
func (request *Request) Logger(level LoggerLevel) *Request
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) IgnoreEncodeErr ¶ added in v1.0.0
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) Logger ¶ added in v1.0.0
func (wk *WuKong) Logger(lv LoggerLevel) *WuKong
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.