mirror of https://github.com/hashicorp/consul
Add HTTP header manip for router and splitter entries
parent
46e4041283
commit
d776a2d236
|
@ -400,6 +400,10 @@ type ServiceRouteDestination struct {
|
||||||
// RetryOnStatusCodes is a flat list of http response status codes that are
|
// RetryOnStatusCodes is a flat list of http response status codes that are
|
||||||
// eligible for retry. This again should be feasible in any reasonable proxy.
|
// eligible for retry. This again should be feasible in any reasonable proxy.
|
||||||
RetryOnStatusCodes []uint32 `json:",omitempty" alias:"retry_on_status_codes"`
|
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) {
|
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
|
// If this field is specified then this route is ineligible for further
|
||||||
// splitting.
|
// splitting.
|
||||||
Namespace string `json:",omitempty"`
|
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
|
// ServiceResolverConfigEntry defines which instances of a service should
|
||||||
|
|
|
@ -463,6 +463,24 @@ func TestDecodeConfigEntry(t *testing.T) {
|
||||||
num_retries = 12345
|
num_retries = 12345
|
||||||
retry_on_connect_failure = true
|
retry_on_connect_failure = true
|
||||||
retry_on_status_codes = [401, 209]
|
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
|
NumRetries = 12345
|
||||||
RetryOnConnectFailure = true
|
RetryOnConnectFailure = true
|
||||||
RetryOnStatusCodes = [401, 209]
|
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,
|
NumRetries: 12345,
|
||||||
RetryOnConnectFailure: true,
|
RetryOnConnectFailure: true,
|
||||||
RetryOnStatusCodes: []uint32{401, 209},
|
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"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -676,6 +722,24 @@ func TestDecodeConfigEntry(t *testing.T) {
|
||||||
{
|
{
|
||||||
weight = 99.1
|
weight = 99.1
|
||||||
service_subset = "v1"
|
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
|
weight = 0.9
|
||||||
|
@ -695,6 +759,24 @@ func TestDecodeConfigEntry(t *testing.T) {
|
||||||
{
|
{
|
||||||
Weight = 99.1
|
Weight = 99.1
|
||||||
ServiceSubset = "v1"
|
ServiceSubset = "v1"
|
||||||
|
RequestHeaders {
|
||||||
|
Add {
|
||||||
|
foo = "bar"
|
||||||
|
}
|
||||||
|
Set {
|
||||||
|
bar = "baz"
|
||||||
|
}
|
||||||
|
Remove = ["qux"]
|
||||||
|
}
|
||||||
|
ResponseHeaders {
|
||||||
|
Add {
|
||||||
|
foo = "bar"
|
||||||
|
}
|
||||||
|
Set {
|
||||||
|
bar = "baz"
|
||||||
|
}
|
||||||
|
Remove = ["qux"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Weight = 0.9
|
Weight = 0.9
|
||||||
|
@ -714,6 +796,16 @@ func TestDecodeConfigEntry(t *testing.T) {
|
||||||
{
|
{
|
||||||
Weight: 99.1,
|
Weight: 99.1,
|
||||||
ServiceSubset: "v1",
|
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,
|
Weight: 0.9,
|
||||||
|
|
Loading…
Reference in New Issue