Skip to content

Commit

Permalink
Merge pull request #263 from alpacahq/set-host
Browse files Browse the repository at this point in the history
Set http request host in rest
  • Loading branch information
noramehesz authored Nov 3, 2023
2 parents 7d04fa9 + 79af9eb commit efb7598
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions marketdata/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type ClientOpts struct {
Currency string
// HTTPClient to be used for each http request.
HTTPClient *http.Client
// Host used to set the http request's host
RequestHost string
}

// Client is the alpaca marketdata Client.
Expand Down Expand Up @@ -89,6 +91,9 @@ var DefaultClient = NewClient(ClientOpts{})

func defaultDo(c *Client, req *http.Request) (*http.Response, error) {
req.Header.Set("User-Agent", alpaca.Version())
if c.opts.RequestHost != "" {
req.Host = c.opts.RequestHost
}

if c.opts.OAuth != "" {
req.Header.Set("Authorization", "Bearer "+c.opts.OAuth)
Expand Down

0 comments on commit efb7598

Please sign in to comment.