Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultClient = http.DefaultClient DefaultTransport = http.DefaultTransport )
Functions ¶
This section is empty.
Types ¶
type AgentOpFunc ¶
func Context ¶
func Context(ctx context.Context) AgentOpFunc
func CustomRespHandler ¶
func CustomRespHandler(handler RespHandler) AgentOpFunc
CustomRespHandler specify a custom RespHandler
func ExpectedStatusCodes ¶
func ExpectedStatusCodes(codes []int) AgentOpFunc
func RespWrapper ¶
func RespWrapper(wrapper Wrapper) AgentOpFunc
func Retry ¶
func Retry(opt *RetryOpt) AgentOpFunc
func SetHeader ¶
func SetHeader(header http.Header) AgentOpFunc
func (AgentOpFunc) InitialAgent ¶
func (f AgentOpFunc) InitialAgent(agent *Agent) error
type HttpCodeErr ¶
func NewHttpCodeErr ¶
func NewHttpCodeErr(expectedCodes []int, resp *http.Response) *HttpCodeErr
func (*HttpCodeErr) Error ¶
func (e *HttpCodeErr) Error() string
type HybridHandler ¶
type HybridHandler struct {
// contains filtered or unexported fields
}
RawRespHandler is a wrapper to implement AgentOp and RespHandler
func HybridResp ¶
func HybridResp(predicate ...RespHandlerPredicate) *HybridHandler
HybridResp can handle hybrid response such as Json and Raw you can use RespHandlerPredicate to indicate when use which resp handler with Predicate
func (*HybridHandler) HandleResponse ¶
func (h *HybridHandler) HandleResponse(resp *http.Response, respWrapper Wrapper) error
func (*HybridHandler) InitialAgent ¶
func (h *HybridHandler) InitialAgent(a *Agent) error
type JsonRespHandler ¶
type JsonRespHandler struct {
// contains filtered or unexported fields
}
JsonRespHandler is a wrapper to implement AgentOp and RespHandler
func JsonResp ¶
func JsonResp(ret interface{}) *JsonRespHandler
JsonResp use to handler json response, ret must be a ptr
func (*JsonRespHandler) HandleResponse ¶
func (h *JsonRespHandler) HandleResponse(resp *http.Response, respWrapper Wrapper) error
func (*JsonRespHandler) InitialAgent ¶
func (h *JsonRespHandler) InitialAgent(a *Agent) error
type RawRespHandler ¶
type RawRespHandler struct {
// contains filtered or unexported fields
}
RawRespHandler is a wrapper to implement AgentOp and RespHandler
func RawResp ¶
func RawResp(resp *http.Response, bs *[]byte) *RawRespHandler
RawResp use http.Response and []byes to accept response
func (*RawRespHandler) HandleResponse ¶
func (h *RawRespHandler) HandleResponse(resp *http.Response, respWrapper Wrapper) error
func (*RawRespHandler) InitialAgent ¶
func (h *RawRespHandler) InitialAgent(a *Agent) error
type ReqPreHandler ¶
type ReqPreHandlerFunc ¶
func (ReqPreHandlerFunc) PreHandleRequest ¶
type RespHandler ¶
RespHandler you can implement some special cases TIPS: Usually JsonResp, RawResp and HybridResp handle most situations
type RespHandlerPredicate ¶
type RespHandlerPredicate struct { Predicate func(response *http.Response) bool RespHandler RespHandler }
Click to show internal directories.
Click to hide internal directories.