-
Notifications
You must be signed in to change notification settings - Fork 347
/
wellknown.go
48 lines (43 loc) · 1.51 KB
/
wellknown.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.
package filters
import (
grpcstats "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_stats/v3"
grpcweb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_web/v3"
httprouter "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3"
hcm "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
"google.golang.org/protobuf/types/known/wrapperspb"
"github.com/envoyproxy/gateway/internal/utils/protocov"
)
var (
GRPCWeb = &hcm.HttpFilter{
Name: wellknown.GRPCWeb,
ConfigType: &hcm.HttpFilter_TypedConfig{
TypedConfig: protocov.ToAny(&grpcweb.GrpcWeb{}),
},
}
GRPCStats = &hcm.HttpFilter{
Name: wellknown.HTTPGRPCStats,
ConfigType: &hcm.HttpFilter_TypedConfig{
TypedConfig: protocov.ToAny(&grpcstats.FilterConfig{
EmitFilterState: true,
PerMethodStatSpecifier: &grpcstats.FilterConfig_StatsForAllMethods{
StatsForAllMethods: &wrapperspb.BoolValue{Value: true},
},
}),
},
}
)
func GenerateRouterFilter(enableEnvoyHeaders bool) *hcm.HttpFilter {
return &hcm.HttpFilter{
Name: wellknown.Router,
ConfigType: &hcm.HttpFilter_TypedConfig{
TypedConfig: protocov.ToAny(&httprouter.Router{
SuppressEnvoyHeaders: !enableEnvoyHeaders,
}),
},
}
}