-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
func NewClient(baseURL string, vHost string, headers map[string]string, httpClient *http.Client) *Client
headers
and httpClient
are often times nil
. I propose to turn them to functional options to make the signature of NewClient
more concise. There could be a dedicated option for X-API-Key
.
func WithHeaders(headers map[string]string)
func WithHttpClient(client *http.Client)
func WithAPIKey(key string)
func NewClient(baseURL string, vHost string, opts ...NewClientOptions) *Client
Usage:
- pdns := NewClient("http://localhost:80", "localhost", map[string]string{"X-API-Key": "apipw"}, nil)
+ pdns := NewClient("http://localhost:80", "localhost", WithAPIKey("apipw"))
Metadata
Metadata
Assignees
Labels
No labels