[management] extend rest client lib (#3830)

This commit is contained in:
Pascal Fischer
2025-05-15 18:20:29 +02:00
committed by GitHub
parent e520b64c6d
commit 43ae79d848
15 changed files with 129 additions and 78 deletions

View File

@@ -0,0 +1,35 @@
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
}
}