@@ -16,12 +16,12 @@ import (
1616 "github.com/apoxy-dev/apoxy/pkg/gateway/ir"
1717 "github.com/apoxy-dev/apoxy/pkg/gateway/xds/types"
1818 "github.com/apoxy-dev/apoxy/pkg/log"
19+ "github.com/envoyproxy/gateway/proto/extension"
1920 clusterv3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
2021 listenerv3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
2122 routev3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
2223 cachetypes "github.com/envoyproxy/go-control-plane/pkg/cache/types"
2324 resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
24- "github.com/envoyproxy/gateway/proto/extension"
2525 "google.golang.org/grpc"
2626 "google.golang.org/grpc/credentials"
2727 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -163,7 +163,8 @@ func processExtensionPostRouteHook(
163163
164164 for _ , r := range tCtx .XdsResources [resourcev3 .RouteType ] {
165165 routeCfg := r .(* routev3.RouteConfiguration )
166- for _ , vh := range routeCfg .GetVirtualHosts () {
166+ for vhIdx := range routeCfg .GetVirtualHosts () {
167+ vh := routeCfg .VirtualHosts [vhIdx ]
167168 for i , route := range vh .GetRoutes () {
168169 log .Info ("Processing extension post route hook" , "route" , route .GetName ())
169170 reqCtx , cancel := context .WithTimeout (ctx , 2 * time .Second )
@@ -178,6 +179,19 @@ func processExtensionPostRouteHook(
178179 vh .Routes [i ] = resp .GetRoute ()
179180 }
180181 }
182+
183+ log .Info ("Processing extension post virtual host hook" , "virtualHost" , vh .GetName ())
184+ vhCtx , vhCancel := context .WithTimeout (ctx , 2 * time .Second )
185+ vhResp , err := c .PostVirtualHostModify (vhCtx , & extension.PostVirtualHostModifyRequest {
186+ VirtualHost : vh ,
187+ })
188+ vhCancel ()
189+ if err != nil {
190+ return err
191+ }
192+ if vhResp .GetVirtualHost () != nil {
193+ routeCfg .VirtualHosts [vhIdx ] = vhResp .GetVirtualHost ()
194+ }
181195 }
182196 }
183197
0 commit comments