Documentation
¶
Index ¶
- Variables
- func InitH2cClient(rwTimeout time.Duration, connectTimeout ...time.Duration)
- func InitHTTPClient(rwTimeout time.Duration, connectTimeout ...time.Duration)
- func InstallPrometheus(serviceName string, p prom)
- func UseMiddleware(handle ...Handler)
- type HTTPRequest
- func (req *HTTPRequest) AddCookie(c *http.Cookie) Request
- func (req *HTTPRequest) AddHeader(key, value string) Request
- func (req *HTTPRequest) Context() context.Context
- func (req *HTTPRequest) Delete() Request
- func (req *HTTPRequest) EnableTrace() Request
- func (req *HTTPRequest) EnableTraceFromMiddleware()
- func (req *HTTPRequest) Get() Request
- func (req *HTTPRequest) GetRequest() *http.Request
- func (req *HTTPRequest) GetRespone() *Response
- func (req *HTTPRequest) GetResponeBody() []byte
- func (req *HTTPRequest) GetStdRequest() *http.Request
- func (req *HTTPRequest) Head() Request
- func (req *HTTPRequest) Header() http.Header
- func (req *HTTPRequest) IsStopped() bool
- func (req *HTTPRequest) Next()
- func (req *HTTPRequest) Options() Request
- func (req *HTTPRequest) Post() Request
- func (req *HTTPRequest) Put() Request
- func (req *HTTPRequest) SetBody(byts []byte) Request
- func (req *HTTPRequest) SetHeader(header http.Header) Request
- func (req *HTTPRequest) SetJSONBody(obj interface{}) Request
- func (req *HTTPRequest) SetQueryParam(key string, value interface{}) Request
- func (req *HTTPRequest) SetQueryParams(m map[string]interface{}) Request
- func (req *HTTPRequest) Singleflight(key ...interface{}) Request
- func (req *HTTPRequest) Stop(e ...error)
- func (req *HTTPRequest) ToBytes() ([]byte, *Response)
- func (req *HTTPRequest) ToJSON(obj interface{}) *Response
- func (req *HTTPRequest) ToString() (string, *Response)
- func (req *HTTPRequest) ToXML(v interface{}) *Response
- func (req *HTTPRequest) URL() string
- func (req *HTTPRequest) WithContext(ctx context.Context) Request
- func (req *HTTPRequest) WithContextFromMiddleware(ctx context.Context)
- type HTTPTraceInfo
- type Handler
- type Middleware
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultH2CClient . DefaultH2CClient *http.Client // DefaultHTTPClient . DefaultHTTPClient *http.Client )
View Source
var Marshal func(v interface{}) ([]byte, error)
Marshal .
View Source
var Unmarshal func(data []byte, v interface{}) error
Unmarshal .
Functions ¶
func InitH2cClient ¶ added in v1.8.0
InitH2cClient .
func InitHTTPClient ¶ added in v1.8.0
InitHTTPClient .
Types ¶
type HTTPRequest ¶ added in v1.8.0
type HTTPRequest struct { StdRequest *http.Request Response Response Params url.Values SingleflightKey string Client *http.Client // contains filtered or unexported fields }
HTTPRequest .
func (*HTTPRequest) AddCookie ¶ added in v1.8.1
func (req *HTTPRequest) AddCookie(c *http.Cookie) Request
AddCookie .
func (*HTTPRequest) AddHeader ¶ added in v1.8.0
func (req *HTTPRequest) AddHeader(key, value string) Request
AddHeader .
func (*HTTPRequest) Context ¶ added in v1.8.1
func (req *HTTPRequest) Context() context.Context
Context .
func (*HTTPRequest) EnableTrace ¶ added in v1.8.1
func (req *HTTPRequest) EnableTrace() Request
EnableTrace .
func (*HTTPRequest) EnableTraceFromMiddleware ¶ added in v1.8.1
func (req *HTTPRequest) EnableTraceFromMiddleware()
EnableTraceFromMiddleware .
func (*HTTPRequest) GetRequest ¶ added in v1.8.0
func (req *HTTPRequest) GetRequest() *http.Request
GetRequest .
func (*HTTPRequest) GetRespone ¶ added in v1.8.0
func (req *HTTPRequest) GetRespone() *Response
GetRespone .
func (*HTTPRequest) GetResponeBody ¶ added in v1.8.1
func (req *HTTPRequest) GetResponeBody() []byte
GetResponeBody .
func (*HTTPRequest) GetStdRequest ¶ added in v1.8.0
func (req *HTTPRequest) GetStdRequest() *http.Request
GetStdRequest .
func (*HTTPRequest) IsStopped ¶ added in v1.8.0
func (req *HTTPRequest) IsStopped() bool
IsStopped .
func (*HTTPRequest) SetBody ¶ added in v1.8.0
func (req *HTTPRequest) SetBody(byts []byte) Request
SetBody .
func (*HTTPRequest) SetHeader ¶ added in v1.8.0
func (req *HTTPRequest) SetHeader(header http.Header) Request
SetHeader .
func (*HTTPRequest) SetJSONBody ¶ added in v1.8.0
func (req *HTTPRequest) SetJSONBody(obj interface{}) Request
SetJSONBody .
func (*HTTPRequest) SetQueryParam ¶ added in v1.8.1
func (req *HTTPRequest) SetQueryParam(key string, value interface{}) Request
SetQueryParam .
func (*HTTPRequest) SetQueryParams ¶ added in v1.8.1
func (req *HTTPRequest) SetQueryParams(m map[string]interface{}) Request
SetQueryParams .
func (*HTTPRequest) Singleflight ¶ added in v1.8.0
func (req *HTTPRequest) Singleflight(key ...interface{}) Request
Singleflight .
func (*HTTPRequest) ToBytes ¶ added in v1.8.0
func (req *HTTPRequest) ToBytes() ([]byte, *Response)
ToBytes .
func (*HTTPRequest) ToJSON ¶ added in v1.8.0
func (req *HTTPRequest) ToJSON(obj interface{}) *Response
ToJSON .
func (*HTTPRequest) ToString ¶ added in v1.8.0
func (req *HTTPRequest) ToString() (string, *Response)
ToString .
func (*HTTPRequest) ToXML ¶ added in v1.8.0
func (req *HTTPRequest) ToXML(v interface{}) *Response
ToXML .
func (*HTTPRequest) WithContext ¶ added in v1.8.0
func (req *HTTPRequest) WithContext(ctx context.Context) Request
WithContext .
func (*HTTPRequest) WithContextFromMiddleware ¶ added in v1.8.1
func (req *HTTPRequest) WithContextFromMiddleware(ctx context.Context)
WithContextFromMiddleware .
type HTTPTraceInfo ¶ added in v1.8.1
type HTTPTraceInfo struct { DNSLookup time.Duration ConnTime time.Duration TCPConnTime time.Duration TLSHandshake time.Duration ServerTime time.Duration ResponseTime time.Duration TotalTime time.Duration IsConnReused bool IsConnWasIdle bool ConnIdleTime time.Duration }
HTTPTraceInfo .
type Middleware ¶
type Middleware interface { Next() Stop(...error) GetRequest() *http.Request GetRespone() *Response GetResponeBody() []byte IsStopped() bool Context() context.Context WithContextFromMiddleware(context.Context) EnableTraceFromMiddleware() }
Middleware .
type Request ¶
type Request interface { Post() Request Put() Request Get() Request Delete() Request Head() Request Options() Request SetJSONBody(obj interface{}) Request SetBody(byts []byte) Request ToJSON(obj interface{}) *Response ToString() (string, *Response) ToBytes() ([]byte, *Response) ToXML(v interface{}) *Response SetQueryParam(key string, value interface{}) Request SetQueryParams(map[string]interface{}) Request URL() string Context() context.Context WithContext(context.Context) Request Singleflight(key ...interface{}) Request SetHeader(header http.Header) Request AddHeader(key, value string) Request Header() http.Header GetStdRequest() *http.Request AddCookie(*http.Cookie) Request EnableTrace() Request }
Request .
type Response ¶
type Response struct { Error error HTTP11 bool ContentType string Status string // e.g. "200 OK" StatusCode int // e.g. 200 Proto string // e.g. "HTTP/1.0" ProtoMajor int // e.g. 1 ProtoMinor int // e.g. 0 Header http.Header ContentLength int64 Uncompressed bool // contains filtered or unexported fields }
Response .
func (*Response) Cookies ¶ added in v1.8.1
Cookies parses and returns the cookies set in the Set-Cookie headers.
func (*Response) ProtoAtLeast ¶ added in v1.8.1
ProtoAtLeast reports whether the HTTP protocol used in the response is at least major.minor.
func (*Response) TraceInfo ¶ added in v1.8.1
func (res *Response) TraceInfo() HTTPTraceInfo
TraceInfo .
Click to show internal directories.
Click to hide internal directories.