Skip to content

Commit

Permalink
Add Host to contextWithClient
Browse files Browse the repository at this point in the history
  • Loading branch information
orloffv committed Jan 24, 2022
1 parent 2c5eb7c commit 64c2543
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ type Info struct {
// this connection.
Auth AuthData

// Host fro the incomping request (http.Request.Host)
Host string

// Metadata is the request metadata from the client connecting to this connector.
// Experimental: *NOTE* this structure is subject to change or removal in the future.
Metadata Metadata
Expand Down
2 changes: 2 additions & 0 deletions config/confighttp/clientinfohandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func contextWithClient(req *http.Request, includeMetadata bool) context.Context
cl.Metadata = client.NewMetadata(req.Header.Clone())
}

cl.Host = req.Host

ctx := client.NewContext(req.Context(), cl)
return ctx
}
Expand Down
9 changes: 9 additions & 0 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@ func TestContextWithClient(t *testing.T) {
Metadata: client.NewMetadata(map[string][]string{"x-test-header": {"test-value"}}),
},
},
{
desc: "request with Host",
input: &http.Request{
Host: "localhost:55443",
},
expected: client.Info{
Host: "localhost:55443",
},
},
}
for _, tC := range testCases {
t.Run(tC.desc, func(t *testing.T) {
Expand Down

0 comments on commit 64c2543

Please sign in to comment.