[shared] allow setting a user agent for the rest client (#5037)

This commit is contained in:
Pascal Fischer
2026-01-06 10:52:36 +01:00
committed by GitHub
parent 7bb4fc3450
commit f022e34287
3 changed files with 62 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ type Client struct {
managementURL string
authHeader string
httpClient HttpClient
userAgent string
// Accounts NetBird account APIs
// see more: https://docs.netbird.io/api/resources/accounts
@@ -128,6 +129,9 @@ func (c *Client) NewRequest(ctx context.Context, method, path string, body io.Re
if body != nil {
req.Header.Add("Content-Type", "application/json")
}
if c.userAgent != "" {
req.Header.Set("User-Agent", c.userAgent)
}
if len(query) != 0 {
q := req.URL.Query()