{"modulePath":"github.com/devdraftengineer/devdraft-go","version":"v0.0.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package option\n\n## Types\n\n```go\ntype HTTPClient interface {\n\tDo(*http.Request) (*http.Response, error)\n}\n```\nHTTPClient is primarily used to describe an [\\*http.Client](/net/http#Client), but also supports custom implementations.\n\nFor bespoke implementations, prefer using an [\\*http.Client](/net/http#Client) with a custom transport. See [http.RoundTripper](/net/http#RoundTripper) for further information.\n\n```go\ntype Middleware = func(*http.Request, MiddlewareNext) (*http.Response, error)\n```\nMiddleware is a function which intercepts HTTP requests, processing or modifying them, and then passing the request to the next middleware or handler in the chain by calling the provided MiddlewareNext function.\n\n```go\ntype MiddlewareNext = func(*http.Request) (*http.Response, error)\n```\nMiddlewareNext is a function which is called by a middleware to pass an HTTP request to the next stage in the middleware chain.\n\n```go\ntype RequestOption = requestconfig.RequestOption\n```\nRequestOption is an option for the requests made by the devdraft API Client which can be supplied to clients, services, and methods. You can read more about this functional options pattern in our [README](https://pkg.go.dev/github.com/devdraftengineer/devdraft-go#readme-requestoptions).\n\n```go\nfunc WithAPIKey(value string) RequestOption\n```\nWithAPIKey returns a RequestOption that sets the client setting \"api\\_key\".\n\n```go\nfunc WithBaseURL(base string) RequestOption\n```\nWithBaseURL returns a RequestOption that sets the BaseURL for the client.\n\nFor security reasons, ensure that the base URL is trusted.\n\n```go\nfunc WithDebugLog(logger *log.Logger) RequestOption\n```\nWithDebugLog logs the HTTP request and response content. If the logger parameter is nil, it uses the default logger.\n\nWithDebugLog is for debugging and development purposes only. It should not be used in production code. The behavior and interface of WithDebugLog is not guaranteed to be stable.\n\n```go\nfunc WithEnvironmentProduction() RequestOption\n```\nWithEnvironmentProduction returns a RequestOption that sets the current environment to be the \"production\" environment. An environment specifies which base URL to use by default.\n\n```go\nfunc WithHTTPClient(client HTTPClient) RequestOption\n```\nWithHTTPClient returns a RequestOption that changes the underlying http client used to make this request, which by default is [http.DefaultClient](/net/http#DefaultClient).\n\nFor custom uses cases, it is recommended to provide an [\\*http.Client](/net/http#Client) with a custom [http.RoundTripper](/net/http#RoundTripper) as its transport, rather than directly implementing [HTTPClient](#HTTPClient).\n\n```go\nfunc WithHeader(key, value string) RequestOption\n```\nWithHeader returns a RequestOption that sets the header value to the associated key. It overwrites any value if there was one already present.\n\n```go\nfunc WithHeaderAdd(key, value string) RequestOption\n```\nWithHeaderAdd returns a RequestOption that adds the header value to the associated key. It appends onto any existing values.\n\n```go\nfunc WithHeaderDel(key string) RequestOption\n```\nWithHeaderDel returns a RequestOption that deletes the header value(s) associated with the given key.\n\n```go\nfunc WithIdempotencyKey(value string) RequestOption\n```\nWithIdempotencyKey returns a RequestOption that sets the client setting \"idempotency\\_key\".\n\n```go\nfunc WithJSONDel(key string) RequestOption\n```\nWithJSONDel returns a RequestOption that deletes the body's JSON value associated with the key. The key accepts a string as defined by the [sjson format](https://github.com/tidwall/sjson).\n\n```go\nfunc WithJSONSet(key string, value any) RequestOption\n```\nWithJSONSet returns a RequestOption that sets the body's JSON value associated with the key. The key accepts a string as defined by the [sjson format](https://github.com/tidwall/sjson).\n\n```go\nfunc WithMaxRetries(retries int) RequestOption\n```\nWithMaxRetries returns a RequestOption that sets the maximum number of retries that the client attempts to make. When given 0, the client only makes one request. By default, the client retries two times.\n\nWithMaxRetries panics when retries is negative.\n\n```go\nfunc WithMiddleware(middlewares ...Middleware) RequestOption\n```\nWithMiddleware returns a RequestOption that applies the given middleware to the requests made. Each middleware will execute in the order they were given.\n\n```go\nfunc WithQuery(key, value string) RequestOption\n```\nWithQuery returns a RequestOption that sets the query value to the associated key. It overwrites any value if there was one already present.\n\n```go\nfunc WithQueryAdd(key, value string) RequestOption\n```\nWithQueryAdd returns a RequestOption that adds the query value to the associated key. It appends onto any existing values.\n\n```go\nfunc WithQueryDel(key string) RequestOption\n```\nWithQueryDel returns a RequestOption that deletes the query value(s) associated with the key.\n\n```go\nfunc WithRequestBody(contentType string, body any) RequestOption\n```\nWithRequestBody returns a RequestOption that provides a custom serialized body with the given content type.\n\nbody accepts an io.Reader or raw \\[]bytes.\n\n```go\nfunc WithRequestTimeout(dur time.Duration) RequestOption\n```\nWithRequestTimeout returns a RequestOption that sets the timeout for each request attempt. This should be smaller than the timeout defined in the context, which spans all retries.\n\n```go\nfunc WithResponseBodyInto(dst any) RequestOption\n```\nWithResponseBodyInto returns a RequestOption that overwrites the deserialization target with the given destination. If provided, we don't deserialize into the default struct.\n\n```go\nfunc WithResponseInto(dst **http.Response) RequestOption\n```\nWithResponseInto returns a RequestOption that copies the [\\*http.Response](/net/http#Response) into the given address.\n\n```go\nfunc WithSecret(value string) RequestOption\n```\nWithSecret returns a RequestOption that sets the client setting \"secret\".\n\n","path":"github.com/devdraftengineer/devdraft-go/option","name":"option","synopsis":"","isRedistributable":true}
