| /* |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package v3 |
| |
| import ( |
| 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" |
| ) |
| |
| import ( |
| mesh_proto "github.com/apache/dubbo-kubernetes/api/mesh/v1alpha1" |
| "github.com/apache/dubbo-kubernetes/pkg/xds/envoy/tags" |
| ) |
| |
| type TagsHeaderConfigurer struct { |
| Tags mesh_proto.MultiValueTagSet |
| } |
| |
| func (t *TagsHeaderConfigurer) Configure(rc *envoy_config_route_v3.RouteConfiguration) error { |
| if len(t.Tags) == 0 { |
| return nil |
| } |
| rc.RequestHeadersToAdd = append(rc.RequestHeadersToAdd, &envoy_config_core_v3.HeaderValueOption{ |
| Header: &envoy_config_core_v3.HeaderValue{Key: tags.TagsHeaderName, Value: tags.Serialize(t.Tags)}, |
| }) |
| return nil |
| } |