Documentation ¶
Index ¶
- Constants
- func Bytes(r *http.Response) ([]byte, error)
- func Drain(r *http.Response) error
- func ResponseErr(r *http.Response) error
- func ResponseErrAndBytes(r *http.Response) ([]byte, error)
- func ResponseErrBytes(r *http.Response) ([]byte, error)
- func ResponseErrOrBytes(r *http.Response) ([]byte, error)
- type Client
- func (c *Client) Do(req *http.Request, options ...RequestOption) (*http.Response, error)
- func (c *Client) Get(url string, options ...RequestOption) (*http.Response, error)
- func (c *Client) Head(url string, options ...RequestOption) (resp *http.Response, err error)
- func (c *Client) Post(url string, contentType string, body io.Reader, options ...RequestOption) (*http.Response, error)
- func (c *Client) PostForm(url string, data urlpkg.Values, options ...RequestOption) (*http.Response, error)
- func (c *Client) PostJsonForm(urlPath string, data hexa.Map, options ...RequestOption) (*http.Response, error)
- type HttpErr
- type RequestOption
- func AuthenticateHeader(header string, tokenType string, token string) RequestOption
- func AuthorizationToken(tokenType string, token string) RequestOption
- func BasicAuth(username string, password string) RequestOption
- func BearerToken(token string) RequestOption
- func QueryParams(params hexa.Map) RequestOption
- type URL
- type URLOption
Constants ¶
View Source
const ( LogModeNone uint = 0 LogModeRequestHeaders uint = 1 << iota LogModeRequestBody LogModeResponseHeaders LogModeResponseBody LogModeRequest = LogModeRequestHeaders | LogModeRequestBody LogModeResponse = LogModeResponseHeaders | LogModeResponseBody LogModeAll = LogModeRequest | LogModeResponse )
Variables ¶
This section is empty.
Functions ¶
func ResponseErr ¶
ResponseErr returns http error if the response is not successful. it drains the response.
func ResponseErrAndBytes ¶
ResponseErrAndBytes returns the response body byes and a http error if the response is not successful.
func ResponseErrBytes ¶
ResponseErrBytes returns the response body and its http error if the response isn't successful. It closes the response's body.
Types ¶
type Client ¶
Client is improved version of the net/http client
func NewClientWithOptions ¶
NewClientWithOptions creates a new HTTP client. base url could be nil. in that case all request urls must be absolute.
func (*Client) PostJsonForm ¶
type RequestOption ¶
RequestOption is like middleware which can change request before the client send it.
func AuthenticateHeader ¶
func AuthenticateHeader(header string, tokenType string, token string) RequestOption
func AuthorizationToken ¶
func AuthorizationToken(tokenType string, token string) RequestOption
func BasicAuth ¶
func BasicAuth(username string, password string) RequestOption
func BearerToken ¶
func BearerToken(token string) RequestOption
func QueryParams ¶
func QueryParams(params hexa.Map) RequestOption
Click to show internal directories.
Click to hide internal directories.