Skip to content

Commit

Permalink
Allow for gRPC and proxy set in rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
ciarams87 committed Nov 11, 2021
1 parent 1e91f2e commit 0a96ebe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/configs/virtualserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions internal/configs/virtualserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`},
},
}
Expand Down

0 comments on commit 0a96ebe

Please sign in to comment.