This commit is contained in:
1 parent
407966fc94
commit
346f6f839f
2 files changed
+29
No files matched your search
@@ -36,6 +36,12 @@ var forwardResponseHeaders = []string{"Content-Type", "Content-Length", "Content
|
||||
// Client calls CarrierNode's HTTP API on behalf of one of the other 6
|
||||
// media-family services.
|
||||
type Client struct {
|
||||
// ProjectKey identifies the service making a request to CarrierNode. It is
|
||||
// optional for backwards compatibility, but when set it lets CarrierNode
|
||||
// attribute internal transfers to the originating project on its traffic
|
||||
// dashboard instead of combining every service under one bucket.
|
||||
ProjectKey string
|
||||
|
||||
// InternalServiceSecret is sent as the X-Internal-Auth header on every
|
||||
// request, so CarrierNode can distinguish trusted service-to-service
|
||||
// calls from public traffic. Empty means no header is sent.
|
||||
@@ -136,6 +142,9 @@ func (c *Client) newRequest(ctx context.Context, baseURL, method, path string, b
|
||||
if secret != "" {
|
||||
request.Header.Set("X-Internal-Auth", secret)
|
||||
}
|
||||
if project := strings.TrimSpace(c.ProjectKey); project != "" {
|
||||
request.Header.Set("X-Project-Key", project)
|
||||
}
|
||||
return request, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user