@@ -44,6 +44,7 @@ type Client struct {
44
44
VPNRegions * VPNRegionsService
45
45
LocationContexts * LocationContextsService
46
46
AccessGroups * AccessGroupsService
47
+ Settings * SettingsService
47
48
}
48
49
49
50
type service struct {
@@ -134,9 +135,22 @@ func NewClient(baseURL, clientID, clientSecret string) (*Client, error) {
134
135
c .VPNRegions = (* VPNRegionsService )(& c .common )
135
136
c .LocationContexts = (* LocationContextsService )(& c .common )
136
137
c .AccessGroups = (* AccessGroupsService )(& c .common )
138
+ c .Settings = (* SettingsService )(& c .common )
137
139
return c , nil
138
140
}
139
141
142
+ // setCommonHeaders sets the standard headers for API requests.
143
+ // It sets Authorization and User-Agent headers, and sets Content-Type to application/json
144
+ // if no Content-Type header is already present.
145
+ func (c * Client ) setCommonHeaders (req * http.Request ) {
146
+ req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , c .Token ))
147
+ req .Header .Set ("User-Agent" , c .UserAgent )
148
+
149
+ if req .Header .Get ("Content-Type" ) == "" {
150
+ req .Header .Set ("Content-Type" , "application/json" )
151
+ }
152
+ }
153
+
140
154
// DoRequest executes an HTTP request with authentication and rate limiting.
141
155
// It automatically adds the Bearer token, sets headers, and handles errors.
142
156
func (c * Client ) DoRequest (req * http.Request ) ([]byte , error ) {
@@ -145,9 +159,7 @@ func (c *Client) DoRequest(req *http.Request) ([]byte, error) {
145
159
return nil , err
146
160
}
147
161
148
- req .Header .Set ("Authorization" , fmt .Sprintf ("Bearer %s" , c .Token ))
149
- req .Header .Set ("User-Agent" , c .UserAgent )
150
- req .Header .Set ("Content-Type" , "application/json" )
162
+ c .setCommonHeaders (req )
151
163
152
164
res , err := c .client .Do (req )
153
165
if err != nil {
0 commit comments