feat: avoid using body in GET requests for AirwallexClient payment provider (#3669)

This commit is contained in:
Cutsin 2025-03-18 20:04:15 +08:00 committed by GitHub
parent aafc16e4f4
commit 73c680d56f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -180,7 +181,11 @@ func (c *AirwallexClient) authRequest(method, url string, body interface{}) (map
return nil, err return nil, err
} }
b, _ := json.Marshal(body) b, _ := json.Marshal(body)
req, _ := http.NewRequest(method, url, bytes.NewBuffer(b)) var reqBody io.Reader
if method != "GET" {
reqBody = bytes.NewBuffer(b)
}
req, _ := http.NewRequest(method, url, reqBody)
req.Header.Set("Authorization", "Bearer "+token) req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
resp, err := c.client.Do(req) resp, err := c.client.Do(req)