diff --git a/pkg/apis/istio/v1alpha3/virtual_service.go b/pkg/apis/istio/v1alpha3/virtual_service.go index 2c61a4c1..c0298a66 100644 --- a/pkg/apis/istio/v1alpha3/virtual_service.go +++ b/pkg/apis/istio/v1alpha3/virtual_service.go @@ -325,6 +325,9 @@ type HTTPRoute struct { // destination. Mirror *Destination `json:"mirror,omitempty"` + // Cross-Origin Resource Sharing policy (CORS). Refer to + // https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + // for further details about cross origin resource sharing. CorsPolicy *CorsPolicy `json:"CorsPolicy,omitempty"` // Additional HTTP headers to add before forwarding a request to the @@ -333,6 +336,33 @@ type HTTPRoute struct { // Http headers to remove before returning the response to the caller RemoveResponseHeaders map[string]string `json:"removeResponseHeaders,omitempty"` + + // Header manipulation rules + Headers *Headers `json:"headers,omitempty"` +} + +// Header manipulation rules +type Headers struct { + // Header manipulation rules to apply before forwarding a request + // to the destination service + Request HeaderOperations `json:"request,omitempty"` + + // Header manipulation rules to apply before returning a response + // to the caller + Response HeaderOperations `json:"response,omitempty"` +} + +// HeaderOperations Describes the header manipulations to apply +type HeaderOperations struct { + // Overwrite the headers specified by key with the given values + Set map[string]string `json:"set"` + + // Append the given values to the headers specified by keys + // (will create a comma-separated list of values) + Add map[string]string `json:"add"` + + // Remove the specified headers + Remove []string `json:"remove"` } // HttpMatchRequest specifies a set of criterion to be met in order for the diff --git a/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go index f843c9be..f3619989 100644 --- a/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go +++ b/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go @@ -283,6 +283,11 @@ func (in *HTTPRoute) DeepCopyInto(out *HTTPRoute) { (*out)[key] = val } } + if in.Headers != nil { + in, out := &in.Headers, &out.Headers + *out = new(Headers) + (*in).DeepCopyInto(*out) + } return } @@ -296,6 +301,59 @@ func (in *HTTPRoute) DeepCopy() *HTTPRoute { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HeaderOperations) DeepCopyInto(out *HeaderOperations) { + *out = *in + if in.Set != nil { + in, out := &in.Set, &out.Set + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Add != nil { + in, out := &in.Add, &out.Add + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Remove != nil { + in, out := &in.Remove, &out.Remove + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HeaderOperations. +func (in *HeaderOperations) DeepCopy() *HeaderOperations { + if in == nil { + return nil + } + out := new(HeaderOperations) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Headers) DeepCopyInto(out *Headers) { + *out = *in + in.Request.DeepCopyInto(&out.Request) + in.Response.DeepCopyInto(&out.Response) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Headers. +func (in *Headers) DeepCopy() *Headers { + if in == nil { + return nil + } + out := new(Headers) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InjectAbort) DeepCopyInto(out *InjectAbort) { *out = *in