Documentation ¶
Index ¶
- type Middleware
- type MiddlewareNext
- type RequestOption
- func WithBaseURL(base string) RequestOption
- func WithEnvironmentProduction() RequestOption
- func WithHTTPClient(client *http.Client) RequestOption
- func WithHeader(key, value string) RequestOption
- func WithHeaderAdd(key, value string) RequestOption
- func WithHeaderDel(key string) RequestOption
- func WithJSONDel(key string) RequestOption
- func WithJSONSet(key string, value interface{}) RequestOption
- func WithMaxRetries(retries int) RequestOption
- func WithMiddleware(middlewares ...Middleware) RequestOption
- func WithQuery(key, value string) RequestOption
- func WithQueryAdd(key, value string) RequestOption
- func WithQueryDel(key string) RequestOption
- func WithRequestTimeout(dur time.Duration) RequestOption
- func WithResponseBodyInto(dst any) RequestOption
- func WithResponseInto(dst **http.Response) RequestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
Middleware is a function which intercepts HTTP requests, processing or modifying them, and then passing the request to the next middleware or handler in the chain by calling the provided MiddlewareNext function.
type MiddlewareNext ¶
MiddlewareNext is a function which is called by a middleware to pass an HTTP request to the next stage in the middleware chain.
type RequestOption ¶
type RequestOption = func(*requestconfig.RequestConfig) error
RequestOption is an option for the requests made by the sam API Client which can be supplied to clients, services, and methods. You can read more about this functional options pattern in our README.
func WithBaseURL ¶
func WithBaseURL(base string) RequestOption
WithBaseURL returns a RequestOption that sets the BaseURL for the client.
func WithEnvironmentProduction ¶
func WithEnvironmentProduction() RequestOption
WithEnvironmentProduction returns a RequestOption that sets the current environment to be the "production" environment. An environment specifies which base URL to use by default.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) RequestOption
WithHTTPClient returns a RequestOption that changes the underlying http.Client used to make this request, which by default is http.DefaultClient.
func WithHeader ¶
func WithHeader(key, value string) RequestOption
WithHeader returns a RequestOption that sets the header value to the associated key. It overwrites any value if there was one already present.
func WithHeaderAdd ¶
func WithHeaderAdd(key, value string) RequestOption
WithHeaderAdd returns a RequestOption that adds the header value to the associated key. It appends onto any existing values.
func WithHeaderDel ¶
func WithHeaderDel(key string) RequestOption
WithHeaderDel returns a RequestOption that deletes the header value(s) associated with the given key.
func WithJSONDel ¶
func WithJSONDel(key string) RequestOption
WithJSONDel returns a RequestOption that deletes the body's JSON value associated with the key. The key accepts a string as defined by the sjson format.
func WithJSONSet ¶
func WithJSONSet(key string, value interface{}) RequestOption
WithJSONSet returns a RequestOption that sets the body's JSON value associated with the key. The key accepts a string as defined by the sjson format.
func WithMaxRetries ¶
func WithMaxRetries(retries int) RequestOption
WithMaxRetries returns a RequestOption that sets the maximum number of retries that the client attempts to make. When given 0, the client only makes one request. By default, the client retries two times.
WithMaxRetries panics when retries is negative.
func WithMiddleware ¶
func WithMiddleware(middlewares ...Middleware) RequestOption
WithMiddleware returns a RequestOption that applies the given middleware to the requests made. Each middleware will execute in the order they were given.
func WithQuery ¶
func WithQuery(key, value string) RequestOption
WithQuery returns a RequestOption that sets the query value to the associated key. It overwrites any value if there was one already present.
func WithQueryAdd ¶
func WithQueryAdd(key, value string) RequestOption
WithQueryAdd returns a RequestOption that adds the query value to the associated key. It appends onto any existing values.
func WithQueryDel ¶
func WithQueryDel(key string) RequestOption
WithQueryDel returns a RequestOption that deletes the query value(s) associated with the key.
func WithRequestTimeout ¶
func WithRequestTimeout(dur time.Duration) RequestOption
WithRequestTimeout returns a RequestOption that sets the timeout for each request attempt. This should be smaller than the timeout defined in the context, which spans all retries.
func WithResponseBodyInto ¶
func WithResponseBodyInto(dst any) RequestOption
WithResponseBodyInto returns a RequestOption that overwrites the deserialization target with the given destination. If provided, we don't deserialize into the default struct.
func WithResponseInto ¶
func WithResponseInto(dst **http.Response) RequestOption
WithResponseInto returns a RequestOption that copies the *http.Response into the given address.