Documentation ¶
Index ¶
- func CombineHandlers(list ...func(w http.ResponseWriter, r *http.Request) (next bool)) func(w http.ResponseWriter, r *http.Request)
- func GetClient() *http.Client
- func SetClient(opts ClientOptions)
- type ClientOptions
- type HttpRequest
- func (r *HttpRequest) AcceptJSON() *HttpRequest
- func (r *HttpRequest) AddHeader(key string, value string) *HttpRequest
- func (r *HttpRequest) AddQuery(key string, value string) *HttpRequest
- func (r *HttpRequest) Body(body io.Reader) *HttpRequest
- func (r *HttpRequest) Clone() *HttpRequest
- func (r *HttpRequest) DELETE(url string) *HttpRequest
- func (r *HttpRequest) GET(url string) *HttpRequest
- func (r *HttpRequest) HEAD(url string) *HttpRequest
- func (r *HttpRequest) JSON(data interface{}) *HttpRequest
- func (r *HttpRequest) OPTIONS(url string) *HttpRequest
- func (r *HttpRequest) POST(url string) *HttpRequest
- func (r *HttpRequest) PUT(url string) *HttpRequest
- func (r *HttpRequest) Send() (*HttpResponse, error)
- func (r *HttpRequest) SetHeader(key string, value string) *HttpRequest
- func (r *HttpRequest) SetQuery(key string, value string) *HttpRequest
- func (r *HttpRequest) TRACE(url string) *HttpRequest
- type HttpResponse
- func (r *HttpResponse) Body() ([]byte, error)
- func (r *HttpResponse) Close() error
- func (r *HttpResponse) Header() http.Header
- func (r *HttpResponse) JSON(data interface{}) error
- func (r *HttpResponse) MustBody() []byte
- func (r *HttpResponse) Origin() *http.Response
- func (r *HttpResponse) Status() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombineHandlers ¶
func CombineHandlers(list ...func(w http.ResponseWriter, r *http.Request) (next bool)) func(w http.ResponseWriter, r *http.Request)
合并多个http中间件,如果中间件返回true表示继续执行下一个
Types ¶
type ClientOptions ¶ added in v1.0.5
type HttpRequest ¶ added in v1.0.5
type HttpRequest struct { Client *http.Client URL string Method string Header http.Header Query url.Values RequestBody io.Reader }
func RequestWithClient ¶ added in v1.0.5
func RequestWithClient(client *http.Client) *HttpRequest
新请求,自己设置Client实例
func (*HttpRequest) AcceptJSON ¶ added in v1.0.5
func (r *HttpRequest) AcceptJSON() *HttpRequest
期望JSON响应
func (*HttpRequest) AddHeader ¶ added in v1.0.5
func (r *HttpRequest) AddHeader(key string, value string) *HttpRequest
添加请求头
func (*HttpRequest) AddQuery ¶ added in v1.0.5
func (r *HttpRequest) AddQuery(key string, value string) *HttpRequest
添加查询参数
func (*HttpRequest) Body ¶ added in v1.0.5
func (r *HttpRequest) Body(body io.Reader) *HttpRequest
设置请求体
func (*HttpRequest) DELETE ¶ added in v1.0.5
func (r *HttpRequest) DELETE(url string) *HttpRequest
DELETE
func (*HttpRequest) JSON ¶ added in v1.0.5
func (r *HttpRequest) JSON(data interface{}) *HttpRequest
设置JSON请求体
func (*HttpRequest) OPTIONS ¶ added in v1.0.5
func (r *HttpRequest) OPTIONS(url string) *HttpRequest
OPTIONS
func (*HttpRequest) SetHeader ¶ added in v1.0.5
func (r *HttpRequest) SetHeader(key string, value string) *HttpRequest
设置请求头
func (*HttpRequest) SetQuery ¶ added in v1.0.5
func (r *HttpRequest) SetQuery(key string, value string) *HttpRequest
设置查询参数
func (*HttpRequest) TRACE ¶ added in v1.0.5
func (r *HttpRequest) TRACE(url string) *HttpRequest
TRACE
type HttpResponse ¶ added in v1.0.5
type HttpResponse struct {
// contains filtered or unexported fields
}
func (*HttpResponse) JSON ¶ added in v1.0.5
func (r *HttpResponse) JSON(data interface{}) error
JSON响应体
func (*HttpResponse) MustBody ¶ added in v1.0.5
func (r *HttpResponse) MustBody() []byte
响应体,如果出错则panic
func (*HttpResponse) Origin ¶ added in v1.0.5
func (r *HttpResponse) Origin() *http.Response
获取原始Response对象
Click to show internal directories.
Click to hide internal directories.