Skip to content

Commit 57ad0f1

Browse files
vladhssvladhanzha
andauthored
Add Content-Type header to requests (#48)
* Add Content-Type header to requests * Do not set Content-Type header in tests --------- Co-authored-by: vladhanzha <[email protected]>
1 parent 335f7d4 commit 57ad0f1

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

cloudconnexa/cloudconnexa.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func (c *Client) DoRequest(req *http.Request) ([]byte, error) {
128128

129129
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.Token))
130130
req.Header.Set("User-Agent", c.UserAgent)
131+
req.Header.Set("Content-Type", "application/json")
131132

132133
res, err := c.client.Do(req)
133134
if err != nil {

cloudconnexa/cloudconnexa_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ func setupMockServer() *httptest.Server {
1515
switch r.URL.Path {
1616
case "/api/v1/oauth/token":
1717
if r.Method == "POST" {
18-
w.Header().Set("Content-Type", "application/json")
1918
response := Credentials{AccessToken: "mocked-token"}
2019
err := json.NewEncoder(w).Encode(response)
2120
if err != nil {
@@ -25,9 +24,7 @@ func setupMockServer() *httptest.Server {
2524
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
2625
}
2726
case "/valid-endpoint":
28-
if r.Method == "GET" {
29-
w.Header().Set("Content-Type", "application/json")
30-
} else {
27+
if r.Method != "GET" {
3128
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
3229
}
3330
default:

0 commit comments

Comments
 (0)