Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 507c8eb

Browse files
committed
ensure query is not encoded
This ensures that arguments to `newRequest` such as `foo/bar?biz=bam` aren't encoded, which will result in 404s from Grafana.
1 parent b9f27bb commit 507c8eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ func New(auth, baseURL string) (*Client, error) {
3939
}, nil
4040
}
4141

42-
func (c *Client) newRequest(method, requestPath string, body io.Reader) (*http.Request, error) {
42+
func (c *Client) newRequest(method, requestPathAndQuery string, body io.Reader) (*http.Request, error) {
4343
url := c.baseURL
44-
url.Path = path.Join(url.Path, requestPath)
44+
pathAndQuery := strings.Split(requestPathAndQuery, "?")
45+
url.Path = path.Join(url.Path, pathAndQuery[0])
46+
if len(pathAndQuery) > 1 {
47+
url.RawQuery = pathAndQuery[1]
48+
}
4549
req, err := http.NewRequest(method, url.String(), body)
4650
if err != nil {
4751
return req, err

0 commit comments

Comments
 (0)