mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 16:56:39 +00:00
36 lines
608 B
Go
36 lines
608 B
Go
package rest
|
|
|
|
import "net/http"
|
|
|
|
type option func(*Client)
|
|
|
|
type HttpClient interface {
|
|
Do(req *http.Request) (*http.Response, error)
|
|
}
|
|
|
|
func WithHttpClient(client HttpClient) option {
|
|
return func(c *Client) {
|
|
c.httpClient = client
|
|
}
|
|
}
|
|
|
|
func WithBearerToken(token string) option {
|
|
return WithAuthHeader("Bearer " + token)
|
|
}
|
|
|
|
func WithPAT(token string) option {
|
|
return WithAuthHeader("Token " + token)
|
|
}
|
|
|
|
func WithManagementURL(url string) option {
|
|
return func(c *Client) {
|
|
c.managementURL = url
|
|
}
|
|
}
|
|
|
|
func WithAuthHeader(value string) option {
|
|
return func(c *Client) {
|
|
c.authHeader = value
|
|
}
|
|
}
|