Documentation
¶
Index ¶
- func DefaultLogger(ctx context.Context, info *TransportInfo)
- func DefaultPooledTransport() *syshttp.Transport
- func RegisterRewriter(proto string, w URLRewriter)
- func RepeatableReadRequest(res *syshttp.Request) ([]byte, error)
- func RepeatableReadResponse(res *syshttp.Response) ([]byte, error)
- type Client
- type DialContextFunc
- type Doer
- type Endpoint
- type HTTPLogger
- type Middleware
- type Option
- func WithAfterHook(hook func(*syshttp.Response)) Option
- func WithBeforeHook(hook func(*syshttp.Request)) Option
- func WithBody(w io.Writer) Option
- func WithHeader(k, v string) Option
- func WithHeaders(hdr map[string]string) Option
- func WithMiddleware(m Middleware) Option
- func WithRetry(opt RetryOption) Option
- func WithTimeout(tm time.Duration) Option
- func WithoutQuery(k string) Option
- type Request
- type Response
- type RetryHook
- type RetryOption
- type ServerOnAnyPort
- type TransportEntity
- type TransportInfo
- type URLRewriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultLogger ¶
func DefaultLogger(ctx context.Context, info *TransportInfo)
func DefaultPooledTransport ¶
func RegisterRewriter ¶
func RegisterRewriter(proto string, w URLRewriter)
Types ¶
type Client ¶
type Client interface { EnableCookie() Client SetTimeout(tm time.Duration) Client DisableKeepAlive(disable bool) Client SetMock(fn Endpoint) Client SetDebug(w HTTPLogger) Client SetRetry(opt RetryOption) Client SetHeader(name, val string) Client SetHeaders(hder map[string]string) Client AddMiddleware(m ...Middleware) Client PrependMiddleware(m ...Middleware) Client AddBeforeHook(hook func(*http.Request)) Client AddAfterHook(hook func(*http.Response)) Client MakeDoer(opts ...Option) Doer DoRequest(req *http.Request, opts ...Option) *Response Do(ctx context.Context, method string, uri string, body io.Reader, opts ...Option) *Response Download(ctx context.Context, uri string, w io.Writer, opts ...Option) error Get(ctx context.Context, uri string, opts ...Option) *Response Post(ctx context.Context, urlstr string, data []byte, opts ...Option) *Response Delete(ctx context.Context, urlstr string, data []byte, opts ...Option) *Response Put(ctx context.Context, urlstr string, data []byte, opts ...Option) *Response PostForm(ctx context.Context, urlstr string, data map[string]interface{}, opts ...Option) *Response PostJSON(ctx context.Context, urlstr string, data interface{}, opts ...Option) *Response WithDialer(dialFn DialContextFunc) Client }
type DialContextFunc ¶
type HTTPLogger ¶
type HTTPLogger func(context.Context, *TransportInfo)
type Middleware ¶
func MiddlewareCheckStatusCode ¶
func MiddlewareCheckStatusCode(fn func(int) bool) Middleware
func MiddlewareSetAllowedStatusCode ¶
func MiddlewareSetAllowedStatusCode(codes ...int) Middleware
func MiddlewareSetBlockedStatusCode ¶
func MiddlewareSetBlockedStatusCode(codes ...int) Middleware
func RetryMiddleware ¶
func RetryMiddleware(retryOpt RetryOption) Middleware
type Option ¶
type Option func(*options)
func WithAfterHook ¶
func WithBeforeHook ¶
func WithHeader ¶
func WithHeaders ¶
func WithRetry ¶
func WithRetry(opt RetryOption) Option
func WithTimeout ¶
func WithoutQuery ¶
type Response ¶
func (*Response) MustGetBody ¶
type RetryOption ¶
type ServerOnAnyPort ¶
type ServerOnAnyPort struct {
// contains filtered or unexported fields
}
ServerOnAnyPort handle
func ListenOnAnyLocalPort ¶
func ListenOnAnyLocalPort(h nethttp.Handler) *ServerOnAnyPort
func ListenOnAnyPort ¶
func ListenOnAnyPort(h nethttp.Handler) *ServerOnAnyPort
ListenOnAnyPort serve http on any port
func (*ServerOnAnyPort) Close ¶
func (sp *ServerOnAnyPort) Close() error
type TransportEntity ¶
type TransportInfo ¶
type TransportInfo struct { Method string URL string Status string StartAt time.Time Cost time.Duration Err error Request *TransportEntity Response *TransportEntity }
Click to show internal directories.
Click to hide internal directories.