Documentation ¶
Index ¶
- Constants
- func Do[R Request[T], T any, E error](client *resty.Client, req R, opts ...RequestOptions) (t T, err error)
- func DoRaw[R Request[T], T any, E error](client *resty.Client, req R, opts ...RequestOptions) (res *resty.Response, t T, err error)
- type Default
- type Error
- type ErrorKind
- type Request
- type RequestOptions
Constants ¶
const ( ErrorBodyFromRequest = iota ErrorExecuteRequest ErrorResponseFromBytes )
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do[R Request[T], T any, E error](client *resty.Client, req R, opts ...RequestOptions) (t T, err error)
Do performs a request using resty.Client with request of type `Request[T]`, response of type `T`, error of type `error`.
Requests without response should specify the `any` type. Requests without typed error should specify the `error` type.
RequestOptions enable modification of the request.
Types ¶
type Default ¶
type Default struct{}
Default is a convenience struct for embedding that provides default (nil) implementation of optional Request[T] methods.
func (Default) PathParams ¶
func (Default) QueryParams ¶
type Request ¶
type Request[T any] interface { Method() string Path() string PathParams() map[string]string QueryParams() map[string]string Headers() map[string]string Body() ([]byte, error) ResponseFromBytes([]byte) (T, error) }
Request[T] represents a request with a response of type T.
type RequestOptions ¶ added in v0.1.4
type RequestOptions func(*resty.Request) *resty.Request
RequestOptions are functions that modify resty.Request and return a reference to it.
Allows for modifying the request where required or where it does not make sense to add to implementations of Request[T].