Documentation
¶
Index ¶
- type HTTPClient
- type Middleware
- type MiddlewareNext
- type RequestOption
- func WithBaseURL(base string) RequestOption
- func WithBearerAuth(value string) RequestOption
- func WithDebugLog(logger *log.Logger) RequestOption
- func WithEnvironmentFathomAnalyticsApiV1() RequestOption
- func WithHTTPClient(client HTTPClient) 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 WithRequestBody(contentType string, body any) 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 HTTPClient ¶
HTTPClient is primarily used to describe an *http.Client, but also supports custom implementations.
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.
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 = requestconfig.RequestOption
RequestOption is an option for the requests made by the Fathom Analytics API Client which can be supplied to clients, services, and methods.
func WithBaseURL ¶
func WithBaseURL(base string) RequestOption
WithBaseURL returns a RequestOption that sets the BaseURL for the client.
For security reasons, ensure that the base URL is trusted.
func WithBearerAuth ¶
func WithBearerAuth(value string) RequestOption
WithBearerAuth returns a RequestOption that sets the client setting "bearerAuth".
func WithDebugLog ¶
func WithDebugLog(logger *log.Logger) RequestOption
WithDebugLog logs the HTTP request and response content. If the logger parameter is nil, it uses the default logger.
WithDebugLog is for debugging and development purposes only. It should not be used in production code. The behavior and interface of WithDebugLog is not guaranteed to be stable.
func WithEnvironmentFathomAnalyticsApiV1 ¶
func WithEnvironmentFathomAnalyticsApiV1() RequestOption
WithEnvironmentFathomAnalyticsApiV1 sets the default base URL to the "fathomanalyticsapiv1" environment.
func WithHTTPClient ¶
func WithHTTPClient(client HTTPClient) 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.
func WithHeaderAdd ¶
func WithHeaderAdd(key, value string) RequestOption
WithHeaderAdd appends a header value, preserving any existing values for the key.
func WithHeaderDel ¶
func WithHeaderDel(key string) RequestOption
WithHeaderDel deletes every header 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.
func WithJSONSet ¶
func WithJSONSet(key string, value interface{}) RequestOption
WithJSONSet returns a RequestOption that sets the body's JSON value associated with the key.
func WithMaxRetries ¶
func WithMaxRetries(retries int) RequestOption
WithMaxRetries returns a RequestOption that sets the maximum number of retries the client attempts. Passing 0 disables retries; 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 requests.
func WithQuery ¶
func WithQuery(key, value string) RequestOption
WithQuery returns a RequestOption that sets the query value to the associated key.
func WithQueryAdd ¶
func WithQueryAdd(key, value string) RequestOption
WithQueryAdd appends a query value, preserving any existing values for the key.
func WithQueryDel ¶
func WithQueryDel(key string) RequestOption
WithQueryDel deletes every query value associated with the given key.
func WithRequestBody ¶
func WithRequestBody(contentType string, body any) RequestOption
WithRequestBody returns a RequestOption that provides a custom serialized body with the given content type.
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.
func WithResponseInto ¶
func WithResponseInto(dst **http.Response) RequestOption
WithResponseInto returns a RequestOption that copies the *http.Response into the given address.