diff --git a/agent/structs/config_entry_discoverychain.go b/agent/structs/config_entry_discoverychain.go index 05841ae0de..cb6ed63198 100644 --- a/agent/structs/config_entry_discoverychain.go +++ b/agent/structs/config_entry_discoverychain.go @@ -400,6 +400,10 @@ type ServiceRouteDestination struct { // RetryOnStatusCodes is a flat list of http response status codes that are // eligible for retry. This again should be feasible in any reasonable proxy. RetryOnStatusCodes []uint32 `json:",omitempty" alias:"retry_on_status_codes"` + + // Allow HTTP header manipulation to be configured. + RequestHeaders *HTTPHeaderModifiers `json:",omitempty" alias:"request_headers"` + ResponseHeaders *HTTPHeaderModifiers `json:",omitempty" alias:"response_headers"` } func (e *ServiceRouteDestination) MarshalJSON() ([]byte, error) { @@ -658,6 +662,12 @@ type ServiceSplit struct { // If this field is specified then this route is ineligible for further // splitting. Namespace string `json:",omitempty"` + + // NOTE: Partition is not represented here by design. Do not add it. + + // Allow HTTP header manipulation to be configured. + RequestHeaders *HTTPHeaderModifiers `json:",omitempty" alias:"request_headers"` + ResponseHeaders *HTTPHeaderModifiers `json:",omitempty" alias:"response_headers"` } // ServiceResolverConfigEntry defines which instances of a service should diff --git a/agent/structs/config_entry_test.go b/agent/structs/config_entry_test.go index 6b8b0c269d..2104bf6ea5 100644 --- a/agent/structs/config_entry_test.go +++ b/agent/structs/config_entry_test.go @@ -463,6 +463,24 @@ func TestDecodeConfigEntry(t *testing.T) { num_retries = 12345 retry_on_connect_failure = true retry_on_status_codes = [401, 209] + request_headers { + add { + foo = "bar" + } + set { + bar = "baz" + } + remove = ["qux"] + } + response_headers { + add { + foo = "bar" + } + set { + bar = "baz" + } + remove = ["qux"] + } } }, { @@ -546,6 +564,24 @@ func TestDecodeConfigEntry(t *testing.T) { NumRetries = 12345 RetryOnConnectFailure = true RetryOnStatusCodes = [401, 209] + RequestHeaders { + Add { + foo = "bar" + } + Set { + bar = "baz" + } + Remove = ["qux"] + } + ResponseHeaders { + Add { + foo = "bar" + } + Set { + bar = "baz" + } + Remove = ["qux"] + } } }, { @@ -629,6 +665,16 @@ func TestDecodeConfigEntry(t *testing.T) { NumRetries: 12345, RetryOnConnectFailure: true, RetryOnStatusCodes: []uint32{401, 209}, + RequestHeaders: &HTTPHeaderModifiers{ + Add: map[string]string{"foo": "bar"}, + Set: map[string]string{"bar": "baz"}, + Remove: []string{"qux"}, + }, + ResponseHeaders: &HTTPHeaderModifiers{ + Add: map[string]string{"foo": "bar"}, + Set: map[string]string{"bar": "baz"}, + Remove: []string{"qux"}, + }, }, }, { @@ -674,13 +720,31 @@ func TestDecodeConfigEntry(t *testing.T) { } splits = [ { - weight = 99.1 - service_subset = "v1" + weight = 99.1 + service_subset = "v1" + request_headers { + add { + foo = "bar" + } + set { + bar = "baz" + } + remove = ["qux"] + } + response_headers { + add { + foo = "bar" + } + set { + bar = "baz" + } + remove = ["qux"] + } }, { - weight = 0.9 - service = "other" - namespace = "alt" + weight = 0.9 + service = "other" + namespace = "alt" }, ] `, @@ -693,13 +757,31 @@ func TestDecodeConfigEntry(t *testing.T) { } Splits = [ { - Weight = 99.1 - ServiceSubset = "v1" + Weight = 99.1 + ServiceSubset = "v1" + RequestHeaders { + Add { + foo = "bar" + } + Set { + bar = "baz" + } + Remove = ["qux"] + } + ResponseHeaders { + Add { + foo = "bar" + } + Set { + bar = "baz" + } + Remove = ["qux"] + } }, { - Weight = 0.9 - Service = "other" - Namespace = "alt" + Weight = 0.9 + Service = "other" + Namespace = "alt" }, ] `, @@ -714,6 +796,16 @@ func TestDecodeConfigEntry(t *testing.T) { { Weight: 99.1, ServiceSubset: "v1", + RequestHeaders: &HTTPHeaderModifiers{ + Add: map[string]string{"foo": "bar"}, + Set: map[string]string{"bar": "baz"}, + Remove: []string{"qux"}, + }, + ResponseHeaders: &HTTPHeaderModifiers{ + Add: map[string]string{"foo": "bar"}, + Set: map[string]string{"bar": "baz"}, + Remove: []string{"qux"}, + }, }, { Weight: 0.9,