mirror of
https://github.com/jimeh/cloudflare-dyndns.git
synced 2026-02-19 10:56:42 +00:00
Initial commit
This commit is contained in:
39
vendor/github.com/cloudflare/cloudflare-go/options.go
generated
vendored
Normal file
39
vendor/github.com/cloudflare/cloudflare-go/options.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package cloudflare
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Option is a functional option for configuring the API client.
|
||||
type Option func(*API) error
|
||||
|
||||
// HTTPClient accepts a custom *http.Client for making API calls.
|
||||
func HTTPClient(client *http.Client) Option {
|
||||
return func(api *API) error {
|
||||
api.httpClient = client
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Headers allows you to set custom HTTP headers when making API calls (e.g. for
|
||||
// satisfying HTTP proxies, or for debugging).
|
||||
func Headers(headers http.Header) Option {
|
||||
return func(api *API) error {
|
||||
api.headers = headers
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// parseOptions parses the supplied options functions and returns a configured
|
||||
// *API instance.
|
||||
func (api *API) parseOptions(opts ...Option) error {
|
||||
// Range over each options function and apply it to our API type to
|
||||
// configure it. Options functions are applied in order, with any
|
||||
// conflicting options overriding earlier calls.
|
||||
for _, option := range opts {
|
||||
err := option(api)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user