Documentation ¶
Index ¶
- Constants
- func ReadJSON(entity any) (io.Reader, error)
- func WriteJSON(resp *http.Response, entity any) error
- func WriteYAML(resp *http.Response, entity any) error
- type Auth
- type AuthenticatedRoundTripper
- type BasicAuth
- type BearerToken
- type Client
- func (client *Client) Context() context.Context
- func (client *Client) Delete(url string, target any, transformers ...RequestTransformer) error
- func (client *Client) Get(url string, target any, transformers ...RequestTransformer) error
- func (client *Client) GetYAML(url string, target any, transformers ...RequestTransformer) error
- func (client *Client) Post(url string, entity, target any, transformers ...RequestTransformer) error
- func (client *Client) Put(url string, entity, target any, transformers ...RequestTransformer) error
- type RequestTransformer
- type URL
Constants ¶
const ( AuthorizationHeader = "Authorization" ContentTypeHeader = "Content-Type" ContentTypeTextPlain = "text/plain" ContentTypeJSON = "application/json" )
const (
BearerPrefix = "Bearer "
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthenticatedRoundTripper ¶
type AuthenticatedRoundTripper struct {
// contains filtered or unexported fields
}
func NewAuthenticatedRoundTripper ¶
func NewAuthenticatedRoundTripper( auth *Auth, transport http.RoundTripper, ) *AuthenticatedRoundTripper
type BearerToken ¶
type BearerToken string
func (BearerToken) String ¶
func (b BearerToken) String() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewNoAuthClient ¶
func (*Client) Delete ¶
func (client *Client) Delete(url string, target any, transformers ...RequestTransformer) error
Delete returns the result of a DELETE request to the specified URL, marshaling the result into target. If the target is nil, the response is discarded.
func (*Client) Get ¶
func (client *Client) Get(url string, target any, transformers ...RequestTransformer) error
Get returns the result of a GET request to the specified URL, marshaled into the target. If the target is nil, the response is discarded.
func (*Client) GetYAML ¶
func (client *Client) GetYAML(url string, target any, transformers ...RequestTransformer) error
Special GET method for YAML content type (used in tests).
func (*Client) Post ¶
func (client *Client) Post(url string, entity, target any, transformers ...RequestTransformer) error
Post returns the result of a POST request to the specified URL, using entity as the body of the request, marshaling the result into target. If the target is nil, the response is discarded.
func (*Client) Put ¶
func (client *Client) Put(url string, entity, target any, transformers ...RequestTransformer) error
Put returns the result of a PUT request to the specified URL, using entity as the body of the request, marshaling the result into target. If the target is nil, the response is discarded.
type RequestTransformer ¶
RequestTransformer is a function that can be used to mutate a request before it is sent (e.g. setting headers).
func WithHost ¶
func WithHost(host string) RequestTransformer
type URL ¶
type URL struct {
// contains filtered or unexported fields
}
URL is a wrapper around url.URL that provides a fluent API for building URLs.
func (*URL) WithQueryParam ¶
WithQueryParam adds the given key-value pair to the URL query.