Skip to content

Commit

Permalink
Add request host override option (#495)
Browse files Browse the repository at this point in the history
Add request host override option
  • Loading branch information
Arthur-Befumo authored Jun 15, 2023
1 parent e2c6f13 commit 2f2a500
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-495.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Add request host override option
links:
- https://github.com/palantir/conjure-go-runtime/pull/495
8 changes: 8 additions & 0 deletions conjure-go-client/httpclient/client_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ func WithUserAgent(userAgent string) ClientOrHTTPClientParam {
return WithSetHeader("User-Agent", userAgent)
}

// WithOverrideRequestHost overrides the request Host from the default URL.Host
func WithOverrideRequestHost(host string) ClientOrHTTPClientParam {
return WithMiddleware(MiddlewareFunc(func(req *http.Request, next http.RoundTripper) (*http.Response, error) {
req.Host = host
return next.RoundTrip(req)
}))
}

// WithMetrics enables the "client.response" metric. See MetricsMiddleware for details.
// The serviceName will appear as the "service-name" tag.
func WithMetrics(tagProviders ...TagsProvider) ClientOrHTTPClientParam {
Expand Down

0 comments on commit 2f2a500

Please sign in to comment.