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 ¶
- type DNSResolverFunc
- type DialContext
- type Message
- 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
- type Request
- func (req *Request) Delete(url string, data interface{}, header http.Header) (*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 ¶
This section is empty.
Types ¶
type DNSResolverFunc ¶
DNSResolver DNS解析
type DialContext ¶
type Message ¶
type Message struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (*Message) Descriptor ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
type Option ¶
type Option func(*options)
func WithClientTrace ¶
func WithClientTrace(t *httptrace.ClientTrace) Option
func WithConnectTimeout ¶
WithConnectTimeout 设置连接超时
func WithCookieJar ¶
func WithDNSResolver ¶
func WithDNSResolver(dnsResolver DNSResolverFunc) Option
func WithEnableDefaultHeader ¶
func WithEnableDefaultHeader() Option
WithEnableDefaultHeader 设置默认header
func WithMaxIdleConnsPerHost ¶
WithMaxIdleConnsPerHost 设置每个host最大空闲连接数
func WithRequestInterceptor ¶
func WithRequestInterceptor(i RequestInterceptor) Option
func WithResponseInterceptor ¶
func WithResponseInterceptor(i ResponseInterceptor) Option
func WithShouldRetryFunc ¶
WithShouldRetryFunc 自定义是否需要重试
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request http请求
func (*Request) PostProtoBuf ¶
func (req *Request) PostProtoBuf(url string, v proto.Message, header http.Header) (*Response, error)
PostProtoBuf 发送protoBuf body
type RequestInterceptor ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response http响应
func (*Response) DecodeJSON ¶
DecodeJSON json decode
func (*Response) DecodeProtoBuf ¶
DecodeProtoBuf protoBuf decode
Click to show internal directories.
Click to hide internal directories.