Documentation ¶
Index ¶
- Variables
- func ContextGetClient(ctx context.Context) (*resty.Client, bool)
- func ContextSetClient(ctx context.Context, client *resty.Client) context.Context
- func ExecuteRequest(ctx context.Context, request, response any) error
- func NewAPIClient(options ...Option) *resty.Client
- type GenericResponse
- type GetRequest
- type JSONResponse
- type Option
- type PostRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrResponseMalformed = errors.New("malformed response") ErrRequestFailed = errors.New("request failed") )
Functions ¶
func ContextGetClient ¶
ContextGetClient is used to retrieve a Resty client from the context.
func ContextSetClient ¶
ContextSetClient is used to store a Resty client for an application in the context.
func ExecuteRequest ¶
ExecuteRequest performs a given request and stores the response in the given response object. If possible, the response will be automatically unmarshaled.
func NewAPIClient ¶
func NewAPIClient(options ...Option) *resty.Client
NewAPIClient will create a new Resty client for use in an application. Options can be provided to configure the client behavior (some options can also be set per-request as per Resty documentation).
Types ¶
type GenericResponse ¶
GenericResponse represents a non-JSON encoded response. The UnMarshal method will be called on the response to unmarshal into the appropriate format.
type JSONResponse ¶
type JSONResponse interface { json.Unmarshaler }
JSONResponse is a JSON encoded response. It will be automatically unmarshaled.
type Option ¶ added in v12.1.0
type Option func(*resty.Client) *resty.Client
Option represents an option that can be used to configure Resty client behavior.
func SetDefaultRetry ¶ added in v12.1.0
func SetDefaultRetry() Option
SetDefaultRetry sets up the client to retry 3 times with an exponential backoff in-between, on any request error.
func SetDefaultTimeout ¶ added in v12.1.0
func SetDefaultTimeout() Option
SetDefaultTimeout sets a default timeout for requests.
func WithInsecureConnections ¶ added in v12.1.0
func WithInsecureConnections() Option
WithInsecureConnections will tell the client to ignore TLS certificate issues.
func WithTLSConfig ¶ added in v12.1.0
WithTLSConfig configures the client with the given tls.Config settings.
type PostRequest ¶
type PostRequest interface { GetRequest RequestBody() json.RawMessage }
PostRequest is a HTTP POST request with the request body provided by Body().