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) MustSend() *HttpResponse
- 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
- func (r *HttpRequest) WithMethod(method string) *HttpRequest
- func (r *HttpRequest) WithURL(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) Map() (map[string]interface{}, error)
- func (r *HttpResponse) MustBody() []byte
- func (r *HttpResponse) MustMap() map[string]interface{}
- 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 ¶
type HttpRequest ¶
type HttpRequest struct { Client *http.Client URL string Method string Header http.Header Query url.Values RequestBody io.Reader }
func (*HttpRequest) AddHeader ¶
func (r *HttpRequest) AddHeader(key string, value string) *HttpRequest
添加请求头
func (*HttpRequest) AddQuery ¶
func (r *HttpRequest) AddQuery(key string, value string) *HttpRequest
添加查询参数
func (*HttpRequest) SetHeader ¶
func (r *HttpRequest) SetHeader(key string, value string) *HttpRequest
设置请求头
func (*HttpRequest) SetQuery ¶
func (r *HttpRequest) SetQuery(key string, value string) *HttpRequest
设置查询参数
func (*HttpRequest) WithMethod ¶
func (r *HttpRequest) WithMethod(method string) *HttpRequest
设置请求方法
type HttpResponse ¶
type HttpResponse struct {
// contains filtered or unexported fields
}
func (*HttpResponse) Map ¶ added in v1.1.1
func (r *HttpResponse) Map() (map[string]interface{}, error)
Map响应体
func (*HttpResponse) MustMap ¶ added in v1.1.1
func (r *HttpResponse) MustMap() map[string]interface{}
Map响应体,如果出错则panic
Click to show internal directories.
Click to hide internal directories.