Documentation
¶
Index ¶
- func ExecuteNewRequest(ctx context.Context, method string, u string, body interface{}, ...) error
- func PathEscapeReserved(value string) string
- func UseDefaultParam[T any](dst *param.Field[T], src *T)
- type HTTPDoer
- type PreRequestOptionFunc
- type RequestConfig
- type RequestOption
- type RequestOptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteNewRequest ¶
func PathEscapeReserved ¶
PathEscapeReserved percent-encodes a path parameter while leaving `/` intact, implementing RFC 6570 reserved expansion (`{+var}`) for parameters the OpenAPI document flags with `allowReserved` — typically a file path or object key.
The slash is part of the route shape for these values: `docs/example.txt` must stay nested under `.../files/docs/example.txt` rather than collapsing into a single `docs%2Fexample.txt` segment that addresses a different backend path. Every `/`-separated segment still goes through url.PathEscape, so all other URL-significant characters are encoded by exactly the same rules as a plain path param and a reserved value cannot smuggle in `?` or `#`.
func UseDefaultParam ¶
Types ¶
type HTTPDoer ¶
This interface is primarily used to describe an *http.Client, but also supports custom HTTP implementations.
type PreRequestOptionFunc ¶
type PreRequestOptionFunc func(*RequestConfig) error
func (PreRequestOptionFunc) Apply ¶
func (s PreRequestOptionFunc) Apply(r *RequestConfig) error
type RequestConfig ¶
type RequestConfig struct {
MaxRetries int
RequestTimeout time.Duration
Context context.Context
Request *http.Request
BaseURL *url.URL
// DefaultBaseURL will be used if BaseURL is not explicitly overridden using
// WithBaseURL.
DefaultBaseURL *url.URL
CustomHTTPDoer HTTPDoer
HTTPClient *http.Client
Middlewares []middleware
APIKey string
// If ResponseBodyInto not nil, then we will attempt to deserialize into
// ResponseBodyInto. If Destination is a []byte, then it will return the body as
// is.
ResponseBodyInto interface{}
// ResponseInto copies the \*http.Response of the corresponding request into the
// given address
ResponseInto **http.Response
Body io.Reader
}
RequestConfig represents all the state related to one request.
Editing the variables inside RequestConfig directly is unstable api. Prefer composing the RequestOption instead if possible.
func NewRequestConfig ¶
func NewRequestConfig(ctx context.Context, method string, u string, body interface{}, dst interface{}, opts ...RequestOption) (*RequestConfig, error)
func PreRequestOptions ¶
func PreRequestOptions(opts ...RequestOption) (RequestConfig, error)
PreRequestOptions is used to collect all the options which need to be known before a call to [RequestConfig.ExecuteNewRequest], such as path parameters or global defaults. PreRequestOptions will return a RequestConfig with the options applied.
Only request option functions of type PreRequestOptionFunc are applied.
func (*RequestConfig) Apply ¶
func (cfg *RequestConfig) Apply(opts ...RequestOption) error
func (*RequestConfig) Clone ¶
func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig
func (*RequestConfig) Execute ¶
func (cfg *RequestConfig) Execute() (err error)
type RequestOption ¶
type RequestOption interface {
Apply(*RequestConfig) error
}
func WithDefaultBaseURL ¶
func WithDefaultBaseURL(baseURL string) RequestOption
WithDefaultBaseURL returns a RequestOption that sets the client's default Base URL. This is always overridden by setting a base URL with WithBaseURL. WithBaseURL should be used instead of WithDefaultBaseURL except in internal code.
type RequestOptionFunc ¶
type RequestOptionFunc func(*RequestConfig) error
func (RequestOptionFunc) Apply ¶
func (s RequestOptionFunc) Apply(r *RequestConfig) error