Documentation ¶
Overview ¶
Package httpclient provides a client for working with HTTP requests, using a method based API.
Index ¶
- func Decode(r *http.Response, val interface{}) error
- type Client
- func (c *Client) Delete(url string, mw ...ClientMiddleware) (*http.Response, error)
- func (c *Client) Do(req *http.Request, rmw []ClientMiddleware) (*http.Response, error)
- func (c *Client) Get(url string, mw ...ClientMiddleware) (*http.Response, error)
- func (c *Client) Path(url string) string
- func (c *Client) Pathf(url string, v ...any) string
- func (c *Client) Post(url string, payload []byte, mw ...ClientMiddleware) (*http.Response, error)
- func (c *Client) Put(url string, payload []byte, mw ...ClientMiddleware) (*http.Response, error)
- func (c *Client) Use(mws ...ClientMiddleware)
- type ClientMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Path ¶
Path will safely join the base URL and the provided path and return a string that can be used in a request.
func (*Client) Pathf ¶
Pathf will call fmt.Sprintf with the provided values and then pass them to Client.Path as a convenience.
func (*Client) Use ¶
func (c *Client) Use(mws ...ClientMiddleware)
type ClientMiddleware ¶
func MwBearerToken ¶
func MwBearerToken(token string) ClientMiddleware
MwBearerToken adds an Authorization header with the 'token' prefix.
Example "Authorization: token abc123"
func MwContentType ¶
func MwContentType(contentType string) ClientMiddleware
Click to show internal directories.
Click to hide internal directories.