{"modulePath":"github.com/devdraftengineer/devdraft-go","version":"v0.0.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package requestconfig\n\n## Functions\n\n```go\nfunc ExecuteNewRequest(ctx context.Context, method string, u string, body any, dst any, opts ...RequestOption) error\n```\n\n## Types\n\n```go\ntype HTTPDoer interface {\n\tDo(req *http.Request) (*http.Response, error)\n}\n```\nThis interface is primarily used to describe an [\\*http.Client](/net/http#Client), but also supports custom HTTP implementations.\n\n```go\ntype PreRequestOptionFunc func(*RequestConfig) error\n```\n\n```go\nfunc (s PreRequestOptionFunc) Apply(r *RequestConfig) error\n```\n\n```go\ntype RequestConfig struct {\n\tMaxRetries     int\n\tRequestTimeout time.Duration\n\tContext        context.Context\n\tRequest        *http.Request\n\tBaseURL        *url.URL\n\t// DefaultBaseURL will be used if BaseURL is not explicitly overridden using\n\t// WithBaseURL.\n\tDefaultBaseURL *url.URL\n\tCustomHTTPDoer HTTPDoer\n\tHTTPClient     *http.Client\n\tMiddlewares    []middleware\n\tAPIKey         string\n\tSecret         string\n\tIdempotencyKey string\n\t// If ResponseBodyInto not nil, then we will attempt to deserialize into\n\t// ResponseBodyInto. If Destination is a []byte, then it will return the body as\n\t// is.\n\tResponseBodyInto any\n\t// ResponseInto copies the \\*http.Response of the corresponding request into the\n\t// given address\n\tResponseInto **http.Response\n\tBody         io.Reader\n}\n```\nRequestConfig represents all the state related to one request.\n\nEditing the variables inside RequestConfig directly is unstable api. Prefer composing the RequestOption instead if possible.\n\n```go\nfunc NewRequestConfig(ctx context.Context, method string, u string, body any, dst any, opts ...RequestOption) (*RequestConfig, error)\n```\n\n```go\nfunc PreRequestOptions(opts ...RequestOption) (RequestConfig, error)\n```\nPreRequestOptions 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](#RequestConfig) with the options applied.\n\nOnly request option functions of type [PreRequestOptionFunc](#PreRequestOptionFunc) are applied.\n\n```go\nfunc (cfg *RequestConfig) Apply(opts ...RequestOption) error\n```\n\n```go\nfunc (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig\n```\n\n```go\nfunc (cfg *RequestConfig) Execute() (err error)\n```\n\n```go\ntype RequestOption interface {\n\tApply(*RequestConfig) error\n}\n```\n\n```go\nfunc WithDefaultBaseURL(baseURL string) RequestOption\n```\nWithDefaultBaseURL 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.\n\n```go\ntype RequestOptionFunc func(*RequestConfig) error\n```\n\n```go\nfunc (s RequestOptionFunc) Apply(r *RequestConfig) error\n```\n\n","path":"github.com/devdraftengineer/devdraft-go/internal/requestconfig","name":"requestconfig","synopsis":"","isRedistributable":true}
