Documentation ¶
Overview ¶
Package httpclient http客户端
Package httpclient is a generated protocol buffer package.
It is generated from these files:
httpclient/test.proto
It has these top-level messages:
Message
Index ¶
- func EnableMetric(m *Metric)
- type DNSResolverFunc
- type DialContext
- type FormatUrl
- type Message
- type Metric
- type Option
- func WithClient(client *http.Client) Option
- func WithClientTrace(t *httptrace.ClientTrace) Option
- func WithConnectTimeout(timeout time.Duration) Option
- func WithCookieJar(cookieJar http.CookieJar) Option
- func WithDNSResolver(dnsResolver DNSResolverFunc) Option
- func WithDebug() Option
- func WithDisableKeepAlive() Option
- func WithEnableDefaultHeader() Option
- func WithMaxIdleConnsPerHost(n int) Option
- func WithProxyURL(proxyURL string) Option
- func WithRequestInterceptor(i RequestInterceptor) Option
- func WithResponseInterceptor(i ResponseInterceptor) Option
- func WithRetryTime(retryTimes int) Option
- func WithShouldRetryFunc(f func(*http.Request, *http.Response, error) bool) Option
- func WithTimeout(timeout time.Duration) Option
- func WithUnixSocketPath(path string) Option
- type Request
- func (req *Request) Delete(url string, data interface{}, header http.Header) (*Response, error)
- func (req *Request) Do(ctx context.Context, method string, url string, data interface{}, ...) (*Response, error)
- func (req *Request) Get(url string, params url.Values, header http.Header) (*Response, error)
- func (req *Request) Post(url string, data interface{}, header http.Header) (*Response, error)
- func (req *Request) PostJSON(url string, data interface{}, header http.Header) (*Response, error)
- func (req *Request) PostProtoBuf(url string, v proto.Message, header http.Header) (*Response, error)
- func (req *Request) Put(url string, data interface{}, header http.Header) (*Response, error)
- func (req *Request) UploadFile(url string, reader io.Reader, filename string, header http.Header, ...) (*Response, error)
- type RequestInterceptor
- type Response
- func (resp *Response) Bytes() ([]byte, error)
- func (resp *Response) DecodeJSON(v interface{}) error
- func (resp *Response) DecodeProtoBuf(v interface{}) error
- func (resp *Response) Discard() (int64, error)
- func (resp *Response) Header() http.Header
- func (resp *Response) IsStatusOK() bool
- func (resp *Response) Raw() *http.Response
- func (resp *Response) String() (string, error)
- func (resp *Response) WriteFile(filename string) (int64, error)
- func (resp *Response) WriteTo(w io.Writer) (int64, error)
- type ResponseInterceptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DNSResolverFunc ¶ added in v1.0.8
DNSResolverFunc DNS解析
type DialContext ¶ added in v1.0.7
type Message ¶ added in v1.1.3
type Message struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (*Message) Descriptor ¶ added in v1.1.3
func (*Message) ProtoMessage ¶ added in v1.1.3
func (*Message) ProtoMessage()
type Metric ¶ added in v1.3.9
type Metric struct {
// contains filtered or unexported fields
}
Metric 统计
type Option ¶ added in v1.0.6
type Option func(*options)
func WithClient ¶ added in v1.0.6
WithClient 自定义http client
func WithClientTrace ¶ added in v1.1.3
func WithClientTrace(t *httptrace.ClientTrace) Option
func WithConnectTimeout ¶ added in v1.0.9
WithConnectTimeout 设置连接超时
func WithCookieJar ¶ added in v1.1.0
func WithDNSResolver ¶ added in v1.0.7
func WithDNSResolver(dnsResolver DNSResolverFunc) Option
func WithDisableKeepAlive ¶ added in v1.0.6
func WithDisableKeepAlive() Option
WithDisableKeepAlive 连接重用
func WithEnableDefaultHeader ¶ added in v1.0.6
func WithEnableDefaultHeader() Option
WithEnableDefaultHeader 设置默认header
func WithMaxIdleConnsPerHost ¶ added in v1.0.9
WithMaxIdleConnsPerHost 设置每个host最大空闲连接数
func WithRequestInterceptor ¶ added in v1.1.3
func WithRequestInterceptor(i RequestInterceptor) Option
func WithResponseInterceptor ¶ added in v1.1.3
func WithResponseInterceptor(i ResponseInterceptor) Option
func WithShouldRetryFunc ¶ added in v1.0.6
WithShouldRetryFunc 自定义是否需要重试
func WithUnixSocketPath ¶ added in v1.2.8
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request http请求
func (*Request) PostProtoBuf ¶ added in v1.1.3
func (req *Request) PostProtoBuf(url string, v proto.Message, header http.Header) (*Response, error)
PostProtoBuf 发送protoBuf body
type RequestInterceptor ¶ added in v1.1.3
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response http响应
func (*Response) DecodeJSON ¶
DecodeJSON json decode
func (*Response) DecodeProtoBuf ¶ added in v1.1.3
DecodeProtoBuf protoBuf decode
Click to show internal directories.
Click to hide internal directories.