Documentation
¶
Index ¶
- Variables
- type Authorization
- type Client
- func (c *Client) AcceptStatus(codes ...int) *Client
- func (c *Client) AddHeader(key, value string) *Client
- func (c *Client) AddHeaders(kvPairs ...string) *Client
- func (c *Client) Auth(auth Authorization) *Client
- func (c *Client) CONNECT(resource string) *Request
- func (c *Client) DELETE(resource string) *Request
- func (c *Client) GET(resource string) *Request
- func (c *Client) HEAD(resource string) *Request
- func (c *Client) NewRequest(method string, rawurl string) *Request
- func (c *Client) OPTIONS(resource string) *Request
- func (c *Client) PATCH(resource string) *Request
- func (c *Client) POST(resource string) *Request
- func (c *Client) PUT(resource string) *Request
- func (c *Client) SetCookies(rawurl string, cookies ...*http.Cookie) *Client
- func (c *Client) SetHeader(key, value string) *Client
- func (c *Client) SetHeaders(kvPairs ...string) *Client
- func (c *Client) TRACE(resource string) *Request
- func (c *Client) Timeout(timeout time.Duration) *Client
- func (c *Client) WithCookies() *Client
- type ContentType
- type ContentTypeError
- type Form
- func (f *Form) Add(key, value string) *Form
- func (f *Form) AddAll(key string, values ...string) *Form
- func (f *Form) AddValues(values url.Values) *Form
- func (*Form) ContentType() string
- func (f *Form) EncodeTo(writer io.Writer) error
- func (f *Form) Multipart() *MultipartForm
- func (f *Form) Set(key, value string) *Form
- func (f *Form) SetValues(values url.Values) *Form
- func (f *Form) Value(value interface{}) *Form
- type MultipartForm
- func (mf *MultipartForm) Add(key, value string) *MultipartForm
- func (mf *MultipartForm) AddAll(keys string, values ...string) *MultipartForm
- func (mf *MultipartForm) AddValues(values url.Values) *MultipartForm
- func (mf *MultipartForm) ContentType() string
- func (mf *MultipartForm) EncodeTo(w io.Writer) error
- func (mf *MultipartForm) File(fieldname, filename string, input flu.Input) *MultipartForm
- func (mf *MultipartForm) Set(key, value string) *MultipartForm
- func (mf *MultipartForm) SetValues(values url.Values) *MultipartForm
- func (mf *MultipartForm) Value(value interface{}) *MultipartForm
- type Request
- func (r *Request) AddHeader(key, value string) *Request
- func (r *Request) AddHeaders(kvPairs ...string) *Request
- func (r *Request) Auth(auth Authorization) *Request
- func (r *Request) BodyEncoder(encoder flu.EncoderTo) *Request
- func (r *Request) BodyInput(input flu.Input) *Request
- func (r *Request) ContentLength(contentLength int64) *Request
- func (r *Request) ContentType(contentType string) *Request
- func (r *Request) Context(ctx context.Context) *Request
- func (r *Request) Execute() *Response
- func (r *Request) QueryParam(key, value string) *Request
- func (r *Request) QueryParams(values url.Values) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetHeaders(kvPairs ...string) *Request
- func (r *Request) URL(url *url.URL) *Request
- type Response
- func (r *Response) CheckContentType(value string) *Response
- func (r *Response) CheckStatus(codes ...int) *Response
- func (r *Response) DecodeBody(decoder flu.DecoderFrom) *Response
- func (r *Response) DecodeBodyTo(out flu.Output) *Response
- func (r *Response) HandleResponse(handler ResponseHandler) *Response
- func (r *Response) Reader() (io.Reader, error)
- type ResponseHandler
- type StatusCodeError
- type Transport
- func (t *Transport) DialContext(fun func(ctx context.Context, network, addr string) (net.Conn, error)) *Transport
- func (t *Transport) DialTimeout(timeout time.Duration) *Transport
- func (t *Transport) ExpectContinueTimeout(value time.Duration) *Transport
- func (t *Transport) ForceAttemptHTTP2(allow bool) *Transport
- func (t *Transport) IdleConnTimeout(value time.Duration) *Transport
- func (t *Transport) MaxConnsPerHost(value int) *Transport
- func (t *Transport) MaxIdleConns(value int) *Transport
- func (t *Transport) MaxIdleConnsPerHost(value int) *Transport
- func (t *Transport) NewClient() *Client
- func (t *Transport) Proxy(proxy func(*http.Request) (*url.URL, error)) *Transport
- func (t *Transport) ProxyURL(rawurl string) *Transport
- func (t *Transport) RateLimiter(rateLimiter flu.RateLimiter) *Transport
- func (t *Transport) ResponseHeaderTimeout(value time.Duration) *Transport
- func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)
- func (t *Transport) TLSClientConfig(value *tls.Config) *Transport
- func (t *Transport) TLSHandshakeTimeout(value time.Duration) *Transport
- type VarargsLengthError
Constants ¶
This section is empty.
Variables ¶
var ( GET = DefaultClient.GET POST = DefaultClient.POST )
var DefaultClient = NewClient(http.DefaultClient)
Functions ¶
This section is empty.
Types ¶
type Authorization ¶
func Basic ¶
func Basic(username, password string) Authorization
func Bearer ¶
func Bearer(token string) Authorization
type Client ¶
Client is a fluent http.Client wrapper.
func (*Client) AcceptStatus ¶
func (*Client) AddHeaders ¶
func (*Client) Auth ¶
func (c *Client) Auth(auth Authorization) *Client
func (*Client) NewRequest ¶
NewRequest creates a NewRequest.
func (*Client) SetCookies ¶
SetCookies sets the http.Client cookies.
func (*Client) SetHeaders ¶
func (*Client) WithCookies ¶
type ContentType ¶
type ContentType interface {
ContentType() string
}
type ContentTypeError ¶
type ContentTypeError string
func (ContentTypeError) Error ¶
func (e ContentTypeError) Error() string
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
func (*Form) ContentType ¶
func (*Form) Multipart ¶
func (f *Form) Multipart() *MultipartForm
type MultipartForm ¶
type MultipartForm struct { *Form // contains filtered or unexported fields }
func NewMultipartForm ¶
func NewMultipartForm() *MultipartForm
func (*MultipartForm) Add ¶
func (mf *MultipartForm) Add(key, value string) *MultipartForm
func (*MultipartForm) AddAll ¶
func (mf *MultipartForm) AddAll(keys string, values ...string) *MultipartForm
func (*MultipartForm) AddValues ¶
func (mf *MultipartForm) AddValues(values url.Values) *MultipartForm
func (*MultipartForm) ContentType ¶
func (mf *MultipartForm) ContentType() string
func (*MultipartForm) File ¶
func (mf *MultipartForm) File(fieldname, filename string, input flu.Input) *MultipartForm
func (*MultipartForm) Set ¶
func (mf *MultipartForm) Set(key, value string) *MultipartForm
func (*MultipartForm) SetValues ¶
func (mf *MultipartForm) SetValues(values url.Values) *MultipartForm
func (*MultipartForm) Value ¶
func (mf *MultipartForm) Value(value interface{}) *MultipartForm
type Request ¶
Request allows to set basic http.Request properties.
func (*Request) AddHeaders ¶
AddHeaders adds request header. kvPairs is an array of key-value pairs and must have even length.
func (*Request) Auth ¶
func (r *Request) Auth(auth Authorization) *Request
func (*Request) ContentLength ¶
func (*Request) ContentType ¶
func (*Request) QueryParam ¶
QueryParam sets a query parameter.
func (*Request) SetHeaders ¶
SetHeaders sets request header. kvPairs is an array of key-value pairs and must have even length.
type Response ¶
type Response struct { *http.Response // Error contains an error in case of a request processing error // or nil in case of success. Error error }
Response is a fluent response wrapper.
func (*Response) CheckContentType ¶
func (*Response) CheckStatus ¶
CheckStatus checks the response status code and sets the error to StatusCodeError if there is no match.
func (*Response) DecodeBody ¶
func (r *Response) DecodeBody(decoder flu.DecoderFrom) *Response
Decode reads the response body.
func (*Response) HandleResponse ¶
func (r *Response) HandleResponse(handler ResponseHandler) *Response
HandleResponse executes a ResponseHandler if no previous handling errors occurred.
type ResponseHandler ¶
type StatusCodeError ¶
func NewStatusCodeError ¶
func NewStatusCodeError(r *http.Response) StatusCodeError
func (StatusCodeError) Error ¶
func (e StatusCodeError) Error() string
type Transport ¶
Transport is a fluent wrapper around *http.Transport.
func NewTransport ¶
func NewTransport() *Transport
NewTransport initializes a new Transport with default settings. This should be equivalent to http.DefaultTransport
func (*Transport) DialContext ¶
func (t *Transport) DialContext(fun func(ctx context.Context, network, addr string) (net.Conn, error)) *Transport
DialContext sets http.Transport.DialContext.
func (*Transport) ExpectContinueTimeout ¶
ExpectContinueTimeout sets http.Transport.ExpectContinueTimeout.
func (*Transport) ForceAttemptHTTP2 ¶
func (*Transport) IdleConnTimeout ¶
IdleConnTimeout sets http.Transport.IdleConnTimeout.
func (*Transport) MaxConnsPerHost ¶
MaxConnsPerHost sets http.Transport.MaxConnsPerHost.
func (*Transport) MaxIdleConns ¶
MaxIdleConns sets http.Transport.MaxIdleConns.
func (*Transport) MaxIdleConnsPerHost ¶
MaxIdleConnsPerHost sets http.Transport.MaxIdleConnsPerHost.
func (*Transport) RateLimiter ¶
func (t *Transport) RateLimiter(rateLimiter flu.RateLimiter) *Transport
func (*Transport) ResponseHeaderTimeout ¶
ResponseHeaderTimeout sets http.Transport.ResponseHeaderTimeout.
func (*Transport) TLSClientConfig ¶
type VarargsLengthError ¶
type VarargsLengthError int
func (VarargsLengthError) Error ¶
func (e VarargsLengthError) Error() string
func (VarargsLengthError) Length ¶
func (e VarargsLengthError) Length() int