Skip to content

Commit

Permalink
add helper function for manipulating headers for outgoing requests - …
Browse files Browse the repository at this point in the history
…supports applying specific headers necessary for assistants routes when using OAuth
  • Loading branch information
austin-denoble committed Jun 16, 2024
1 parent 584300a commit 895319d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions internal/pkg/utils/network/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,24 @@ func buildRequest(verb string, path string, bodyJson []byte) (*http.Request, err
}
}

applyHeaders(req, path)

return req, nil
}

func applyHeaders(req *http.Request, url string) {
// request-specific headers
if strings.Contains(url, "assistant") {
req.Header.Set("X-Project-Id", state.TargetProj.Get().Id)
}
if strings.Contains(url, "chat/completions") {
req.Header.Set("X-Disable-Bearer-Auth", "true")
}

// apply to all requests
req.Header.Add("User-Agent", "Pinecone CLI")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Project-Id", state.TargetProj.Get().Id)
req.Header.Set("X-Disable-Bearer-Auth", "true")

return req, nil
}

func performRequest(req *http.Request) (*http.Response, error) {
Expand Down

0 comments on commit 895319d

Please sign in to comment.