mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 00:36:38 +00:00
[misc] Move shared components to shared directory (#4286)
Moved the following directories: ``` - management/client → shared/management/client - management/domain → shared/management/domain - management/proto → shared/management/proto - signal/client → shared/signal/client - signal/proto → shared/signal/proto - relay/client → shared/relay/client - relay/auth → shared/relay/auth ``` and adjusted import paths
This commit is contained in:
44
shared/management/client/rest/options.go
Normal file
44
shared/management/client/rest/options.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package rest
|
||||
|
||||
import "net/http"
|
||||
|
||||
// option modifier for creation of Client
|
||||
type option func(*Client)
|
||||
|
||||
// HTTPClient interface for HTTP client
|
||||
type HttpClient interface {
|
||||
Do(req *http.Request) (*http.Response, error)
|
||||
}
|
||||
|
||||
// WithHTTPClient overrides HTTPClient used
|
||||
func WithHttpClient(client HttpClient) option {
|
||||
return func(c *Client) {
|
||||
c.httpClient = client
|
||||
}
|
||||
}
|
||||
|
||||
// WithBearerToken uses provided bearer token acquired from SSO for authentication
|
||||
func WithBearerToken(token string) option {
|
||||
return WithAuthHeader("Bearer " + token)
|
||||
}
|
||||
|
||||
// WithPAT uses provided Personal Access Token
|
||||
// (created from NetBird Management Dashboard) for authentication
|
||||
func WithPAT(token string) option {
|
||||
return WithAuthHeader("Token " + token)
|
||||
}
|
||||
|
||||
// WithManagementURL overrides target NetBird Management server
|
||||
func WithManagementURL(url string) option {
|
||||
return func(c *Client) {
|
||||
c.managementURL = url
|
||||
}
|
||||
}
|
||||
|
||||
// WithAuthHeader overrides auth header completely, this should generally not be used
|
||||
// and WithBearerToken or WithPAT should be used instead
|
||||
func WithAuthHeader(value string) option {
|
||||
return func(c *Client) {
|
||||
c.authHeader = value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user