Documentation ¶
Index ¶
- Variables
- type Client
- type Req
- func (r *Req) Clone() *Req
- func (r *Req) Do() *Resp
- func (r *Req) GetBody() []byte
- func (r *Req) GetClient() Client
- func (r *Req) GetContext() context.Context
- func (r *Req) Use(wrappers ...wrapper.CallWrapper) *Req
- func (r *Req) WithClient(c Client) *Req
- func (r *Req) WithMethod(method string) *Req
- func (r *Req) WithURL(rawURL string) *Req
- type Resp
- func (r *Resp) AsBytes() ([]byte, error)
- func (r *Resp) AsFile(dest string) error
- func (r *Resp) AsJSONMap() (map[string]interface{}, error)
- func (r *Resp) AsJSONStruct(v interface{}) error
- func (r *Resp) AsReader() (io.Reader, error)
- func (r *Resp) AsString() (string, error)
- func (r *Resp) AsStruct(v interface{}, unmarshal func([]byte, interface{}) error) error
- func (r *Resp) AsXMLMap() (map[string]interface{}, error)
- func (r *Resp) AsXMLStruct(v interface{}) error
- func (r *Resp) Bytes() []byte
- func (r *Resp) Consume(read bool)
- func (r *Resp) ContentLength() int64
- func (r *Resp) ContentType() string
- func (r *Resp) StatusCode() int
- func (r *Resp) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoTransport = errors.New("req: no transport") ErrNoURL = errors.New("req: url not specified") ErrLackParam = errors.New("req: lack param") ErrNoParser = errors.New("resp: no parser") ErrNoFileMatch = errors.New("req: no file match") ErrNotSupportedBody = errors.New("req: not supported body") ErrNoUnmarshal = errors.New("resp: no unmarshal") ErrNoMarshal = errors.New("req: no marshal") ErrParseStruct = errors.New("req: can not parse struct param") ErrBlocked = errors.New("req: circuit breaker blocked") )
define errors
View Source
var (
DefaultClient = NewClient()
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Resp ¶
type Resp struct { Request *http.Request Response *http.Response Error error Cost time.Duration Timeout bool // contains filtered or unexported fields }
Resp represents a http response
func (*Resp) AsBytes ¶
AsBytes returns response body as []byte, return error if error happend when reading the response body
func (*Resp) AsJSONStruct ¶
AsJSONStruct convert json response body to struct or map
func (*Resp) AsString ¶
AsString returns response body as string, return error if error happend when reading the response body
func (*Resp) AsXMLStruct ¶
AsXMLStruct convert xml response body to struct or map
func (*Resp) ContentLength ¶
ContentLength returns content length
Directories ¶
Path | Synopsis |
---|---|
wechat
Module
|
|
plugins
|
|
breaker/hystrix
Module
|
|
codec/sonic
Module
|
|
encoding/br
Module
|
|
prometheus
Module
|
|
trace
Module
|
|
vo
module
|
|
breaker/hystrix
Module
|
|
prometheus
Module
|
|
trace
Module
|
Click to show internal directories.
Click to hide internal directories.