From 0a96ebe0673e5d0a8fda14caf5df8319f074b588 Mon Sep 17 00:00:00 2001 From: Ciara Stacke Date: Tue, 9 Nov 2021 13:07:28 +0000 Subject: [PATCH] Allow for gRPC and proxy set in rewrite --- internal/configs/virtualserver.go | 7 +++---- internal/configs/virtualserver_test.go | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/configs/virtualserver.go b/internal/configs/virtualserver.go index 9352fec5e8..c7f786561b 100644 --- a/internal/configs/virtualserver.go +++ b/internal/configs/virtualserver.go @@ -1339,11 +1339,10 @@ func upstreamHasKeepalive(upstream conf_v1.Upstream, cfgParams *ConfigParams) bo } func generateRewrites(path string, proxy *conf_v1.ActionProxy, internal bool, originalPath string, grpcEnabled bool) []string { - if grpcEnabled && internal { - return []string{"^ $request_uri break"} - } - if proxy == nil || proxy.RewritePath == "" { + if grpcEnabled && internal { + return []string{"^ $request_uri break"} + } return nil } diff --git a/internal/configs/virtualserver_test.go b/internal/configs/virtualserver_test.go index 796613db3c..a3f2388131 100644 --- a/internal/configs/virtualserver_test.go +++ b/internal/configs/virtualserver_test.go @@ -6838,6 +6838,13 @@ func TestGenerateRewrites(t *testing.T) { }, originalPath: "/path", grpcEnabled: true, + expected: []string{`^ $request_uri`, `"^/path(.*)$" "/rewrite$1" break`}, + }, + { + path: "/_internal_path", + internal: true, + originalPath: "/path", + grpcEnabled: true, expected: []string{`^ $request_uri break`}, }, }