Documentation
¶
Index ¶
- Variables
- type Client
- type IntoOptions
- type Opt
- type PathParam
- type QueryParam
- type Request
- func (r *Request) AddHeader(key, value string)
- func (r *Request) Body(obj interface{}) *Request
- func (r *Request) Do(ctx context.Context) Result
- func (r *Request) GetBody() io.Reader
- func (r *Request) GetParams() []QueryParam
- func (r *Request) Params(args ...QueryParam) *Request
- func (r *Request) Path(path string, args ...PathParam) *Request
- func (r *Request) Stream(ctx context.Context) (io.ReadCloser, error)
- func (r *Request) Verb(verb string) *Request
- func (r *Request) WsConn(ctx context.Context) (*websocket.Conn, *http.Response, error)
- type RequestMiddleware
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( DefaultCodeField = "code" DefaultDataField = "data" DefaultMessageField = "msg" )
Functions ¶
This section is empty.
Types ¶
type IntoOptions ¶ added in v0.6.0
type Opt ¶
type Opt func(client *client) error
func WithClient ¶ added in v0.5.0
func WithHeaders ¶
func WithRequestMiddleware ¶ added in v0.7.0
func WithRequestMiddleware(middleware RequestMiddleware) Opt
func WithRetryDelay ¶
func WithRetryTimes ¶
type QueryParam ¶
type QueryParam struct { Name string Value interface{} }
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request allows for building up a request to a server in a chained fashion. Any errors are stored until the end of your call, so you only have to check once.
func NewRequest ¶
func NewRequest(c *client) *Request
func (*Request) Body ¶
Body makes the request use obj as the body. Optional. If obj is a string, try to read a file of that name. If obj is a []byte, send it directly. default marshal it
func (*Request) Do ¶
Do format and executes the request. Returns a Result object for easy response processing.
Error type: http.Client.Do errors are returned directly.
func (*Request) GetParams ¶ added in v0.7.0
func (r *Request) GetParams() []QueryParam
func (*Request) Params ¶
func (r *Request) Params(args ...QueryParam) *Request
type RequestMiddleware ¶ added in v0.7.0
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result contains the result of calling Request.Do().
func (Result) Into ¶
func (r Result) Into(obj interface{}, options *IntoOptions) error
Into stores the result into obj, if possible. If obj is nil it is ignored.
func (Result) RawResponse ¶
func (Result) StatusCode ¶
StatusCode returns the HTTP status code of the request. (Only valid if no error was returned.)