Documentation
¶
Overview ¶
Package client provides a simple, generic HTTP client for sending GET and POST requests to external services, which is used by other packages under pkg/api.
Index ¶
Constants ¶
const ( Timeout = 3 * time.Second MaxSize = 4 << 20 // 4 MiB. AcceptJSON = "application/json" AcceptText = "text/plain" )
Variables ¶
This section is empty.
Functions ¶
func HTTPRequest ¶
func HTTPRequest(ctx context.Context, httpMethod, u, authToken, accept string, queryOrJSONBody any) ([]byte, int, error)
HTTPRequest sends an HTTP GET or POST request to an external API service.
For GET requests, the queryOrJSONBody parameter is expected to be url.Values. For other request methods (e.g. POST), it should be any struct that can be encoded as JSON.
Some errors (failure to construct a request or decode a response body) are returned as non-retryable temporal.ApplicationErrors.
On HTTP 429 (Too Many Requests) responses, the second return value contains the number of seconds to wait before retrying the request.
Types ¶
This section is empty.