Documentation ¶
Index ¶
- Constants
- func DefaultClient() *http.Client
- func DefaultPooledClient() *http.Client
- func DefaultPooledTransport() *http.Transport
- func DefaultTransport() *http.Transport
- type Cfg
- type Client
- type DebugRequestTransport
- type Request
- func (r *Request) Client() bool
- func (r *Request) Codec() encoding.Codec
- func (r *Request) ContentType() string
- func (r *Request) Endpoint() string
- func (r *Request) Header() types.Header
- func (r *Request) Kind() string
- func (r *Request) Method() string
- func (r *Request) Payload() interface{}
- func (r *Request) Read() ([]byte, error)
- func (r *Request) Service() string
- func (r *Request) Stream() bool
- type Response
- func Delete(ctx context.Context, url string, data interface{}, ...) (*Response, error)
- func Do(ctx context.Context, req *Request) (*Response, error)
- func Get(ctx context.Context, url string, requests ...func(req *Request)) (*Response, error)
- func Patch(ctx context.Context, url string, data interface{}, ...) (*Response, error)
- func Post(ctx context.Context, url string, data interface{}, ...) (*Response, error)
- func PostForm(ctx context.Context, url string, val url.Values, ...) (*Response, error)
- func Put(ctx context.Context, url string, data interface{}, ...) (*Response, error)
- type Uploader
- func (u *Uploader) AddFile(formname, filename string, fileReader io.Reader) *Uploader
- func (u *Uploader) AddParam(name, value string) *Uploader
- func (u *Uploader) AddParams(params map[string][]string) *Uploader
- func (u *Uploader) Body() (io.Reader, error)
- func (u *Uploader) ContentType() string
- func (u *Uploader) SetBoundary(boundary string) *Uploader
- func (u *Uploader) SetParams(params map[string][]string) *Uploader
Constants ¶
const Name = "restc"
Variables ¶
This section is empty.
Functions ¶
func DefaultClient ¶
DefaultClient returns a new http.Client with similar default values to http.Client, but with a non-shared Transport, idle connections disabled, and keepalives disabled.
func DefaultPooledClient ¶
DefaultPooledClient returns a new http.Client with similar default values to http.Client, but with a shared Transport. Do not use this function for transient clients as it can leak file descriptors over time. Only use this for clients that will be re-used for the same host(s).
func DefaultPooledTransport ¶
DefaultPooledTransport returns a new http.Transport with similar default values to http.DefaultTransport. Do not use this for transient transports as it can leak file descriptors over time. Only use this for transports that will be re-used for the same host(s).
func DefaultTransport ¶
DefaultTransport returns a new http.Transport with similar default values to http.DefaultTransport, but with idle connections and keepalives disabled.
Types ¶
type Cfg ¶
type Cfg struct { Token string KeepAlive bool Timeout time.Duration RetryCount uint32 Name string NoDefaultUserAgentHeader bool DialDualStack bool MaxConnsPerHost int MaxIdleConnDuration time.Duration MaxConnDuration time.Duration MaxIdemponentCallAttempts int ReadBufferSize int WriteBufferSize int ReadTimeout time.Duration WriteTimeout time.Duration MaxResponseBodySize int DisableHeaderNamesNormalizing bool DisablePathNormalizing bool MaxConnWaitTimeout time.Duration Proxy bool Socks5 string CertPath string KeyPath string Insecure bool Header map[string]string Middlewares []types.Middleware // contains filtered or unexported fields }
func DefaultCfg ¶
func DefaultCfg() Cfg
type Client ¶
type Client interface { Do(ctx context.Context, req *Request) (*http.Response, error) Get(ctx context.Context, url string, requests ...func(req *Request)) (*http.Response, error) Delete(ctx context.Context, url string, data interface{}, requests ...func(req *Request)) (*http.Response, error) Post(ctx context.Context, url string, data interface{}, requests ...func(req *Request)) (*http.Response, error) PostForm(ctx context.Context, url string, val url.Values, requests ...func(req *Request)) (*http.Response, error) Put(ctx context.Context, url string, data interface{}, requests ...func(req *Request)) (*http.Response, error) Patch(ctx context.Context, url string, data interface{}, requests ...func(req *Request)) (*http.Response, error) }
Client http clientImpl interface
type DebugRequestTransport ¶
type DebugRequestTransport struct { RequestHeader bool RequestBody bool // RequestHeader 为 true 时,这个选项才会生效 ResponseHeader bool ResponseBody bool // ResponseHeader 为 true 时,这个选项才会生效 // debug 信息输出到 Writer 中, 默认是 os.Stderr Writer io.Writer Transport http.RoundTripper }
DebugRequestTransport 会打印请求和响应信息, 方便调试.
type Request ¶
func (*Request) ContentType ¶ added in v0.1.18
type Uploader ¶
type Uploader struct {
// contains filtered or unexported fields
}