Documentation ¶
Index ¶
- Constants
- func NewRequestFromOptions(method string, path string, o RequestOptions) (*http.Request, error)
- type Client
- func (c *Client) Config(opt Options) *Client
- func (c *Client) Delete(url string, opts ...RequestOptions) (*PendingRequest, error)
- func (c *Client) Get(url string, opts ...RequestOptions) (*PendingRequest, error)
- func (c *Client) Head(url string, opts ...RequestOptions) (*PendingRequest, error)
- func (c *Client) Interceptor(pf PipeFunc) *Client
- func (c *Client) Patch(url string, opts ...RequestOptions) (*PendingRequest, error)
- func (c *Client) Post(url string, opts ...RequestOptions) (*PendingRequest, error)
- func (c *Client) Put(url string, opts ...RequestOptions) (*PendingRequest, error)
- func (c *Client) Request(method, url string, opts ...RequestOptions) (*PendingRequest, error)
- type ErrorHandler
- type Handler
- type HttpError
- type Options
- type PendingRequest
- func Delete(url string, opts ...RequestOptions) (*PendingRequest, error)
- func Download(url string, filename string, opts ...RequestOptions) (*PendingRequest, error)
- func Get(url string, opts ...RequestOptions) (*PendingRequest, error)
- func Patch(url string, opts ...RequestOptions) (*PendingRequest, error)
- func Post(url string, opts ...RequestOptions) (*PendingRequest, error)
- func Put(url string, opts ...RequestOptions) (*PendingRequest, error)
- func Request(method, url string, opts ...RequestOptions) (*PendingRequest, error)
- type PipeFunc
- type Pipeline
- type ProgressHandler
- type RequestOptions
- type Result
- type UploadFile
Constants ¶
View Source
const ( DefaultTimeout = 5 * time.Second NoneProxy = "none" )
Variables ¶
This section is empty.
Functions ¶
func NewRequestFromOptions ¶
NewRequestFromOptions new http request from RequestOptions
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is request clinet
var DefaultClient *Client
func (*Client) Delete ¶
func (c *Client) Delete(url string, opts ...RequestOptions) (*PendingRequest, error)
Delete send DELETE http request
func (*Client) Get ¶
func (c *Client) Get(url string, opts ...RequestOptions) (*PendingRequest, error)
Get send GET http request
func (*Client) Head ¶ added in v0.0.3
func (c *Client) Head(url string, opts ...RequestOptions) (*PendingRequest, error)
Head send HEAD http request
func (*Client) Interceptor ¶
func (*Client) Patch ¶
func (c *Client) Patch(url string, opts ...RequestOptions) (*PendingRequest, error)
Patch send PATCH http request
func (*Client) Post ¶
func (c *Client) Post(url string, opts ...RequestOptions) (*PendingRequest, error)
Post send POST http request
func (*Client) Put ¶
func (c *Client) Put(url string, opts ...RequestOptions) (*PendingRequest, error)
Put send PUT http request
func (*Client) Request ¶
func (c *Client) Request(method, url string, opts ...RequestOptions) (*PendingRequest, error)
Request send http request
type ErrorHandler ¶
type ErrorHandler func(error)
type Options ¶
type Options struct { // BaseURI is prefix of request url BaseURI string // Timeout request timeout Timeout time.Duration // ProxyURL set proxy url for request ProxyURL string // HttpErrors trigger error if response is not ok HttpErrors bool }
Options is request client options
type PendingRequest ¶
type PendingRequest struct {
// contains filtered or unexported fields
}
func Delete ¶
func Delete(url string, opts ...RequestOptions) (*PendingRequest, error)
func Download ¶ added in v0.0.3
func Download(url string, filename string, opts ...RequestOptions) (*PendingRequest, error)
func Get ¶
func Get(url string, opts ...RequestOptions) (*PendingRequest, error)
func Patch ¶
func Patch(url string, opts ...RequestOptions) (*PendingRequest, error)
func Post ¶
func Post(url string, opts ...RequestOptions) (*PendingRequest, error)
func Put ¶
func Put(url string, opts ...RequestOptions) (*PendingRequest, error)
func Request ¶
func Request(method, url string, opts ...RequestOptions) (*PendingRequest, error)
func (*PendingRequest) Catch ¶
func (pr *PendingRequest) Catch(cb ErrorHandler)
func (*PendingRequest) IsSuccess ¶
func (pr *PendingRequest) IsSuccess() bool
func (*PendingRequest) Then ¶
func (pr *PendingRequest) Then(cb interface{}) error
func (*PendingRequest) Wait ¶
func (pr *PendingRequest) Wait() *Result
type ProgressHandler ¶ added in v0.0.3
type ProgressHandler func(now, total int64)
type RequestOptions ¶
type RequestOptions struct { // Body is raw request body Body io.Reader // Handler is request handler Handler Handler // Json body of request Json interface{} // Header is request header Header http.Header // FormParams is request form params FormParams url.Values // Query is request query Query url.Values // Method is request method Method string // OnProgress handle content download progress OnProgress ProgressHandler // Sink response content to io.Writer, for file download Sink io.Writer // Upload file Upload *UploadFile }
RequestOptions simplified http request options
type Result ¶
func (*Result) ContentString ¶
type UploadFile ¶ added in v0.0.3
type UploadFile struct {
// contains filtered or unexported fields
}
func NewUploadFile ¶ added in v0.0.3
func NewUploadFile(file io.Reader, key, filename string) *UploadFile
Click to show internal directories.
Click to hide internal directories.