diff --git a/internal/controlplane/xds_routes.go b/internal/controlplane/xds_routes.go index fbca5ab0c..3f521a260 100644 --- a/internal/controlplane/xds_routes.go +++ b/internal/controlplane/xds_routes.go @@ -3,6 +3,7 @@ package controlplane import ( "fmt" + envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" envoy_type_matcher_v3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" "github.com/golang/protobuf/ptypes/any" @@ -121,6 +122,17 @@ func (srv *Server) buildPolicyRoutes(options config.Options, domain string) []*e clusterName, _, _ := srv.getClusterDetails(policy.Destination) + var requestHeadersToAdd []*envoy_config_core_v3.HeaderValueOption + for k, v := range policy.SetRequestHeaders { + requestHeadersToAdd = append(requestHeadersToAdd, &envoy_config_core_v3.HeaderValueOption{ + Header: &envoy_config_core_v3.HeaderValue{ + Key: k, + Value: v, + }, + Append: &wrappers.BoolValue{Value: false}, + }) + } + routes = append(routes, &envoy_config_route_v3.Route{ Name: fmt.Sprintf("policy-%d", i), Match: match, @@ -138,6 +150,7 @@ func (srv *Server) buildPolicyRoutes(options config.Options, domain string) []*e }, }, }, + RequestHeadersToAdd: requestHeadersToAdd, }) } return routes