Skip to content

Commit cadacd4

Browse files
committed
update map templates
1 parent e1de7fd commit cadacd4

File tree

5 files changed

+7
-24
lines changed

5 files changed

+7
-24
lines changed

internal/mode/static/nginx/config/base_http_config_template.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ map $http_upgrade $connection_upgrade {
1818
default upgrade;
1919
'' close;
2020
}
21+
22+
## Returns just the path from the original request URI.
23+
map $request_uri $request_uri_path {
24+
"~^(?P<path>[^?]*)(\?.*)?$" $path;
25+
}
2126
`

internal/mode/static/nginx/config/base_http_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ func TestExecuteBaseHttp(t *testing.T) {
4949
g.Expect(test.expCount).To(Equal(strings.Count(string(res[0].data), expSubStr)))
5050
g.Expect(strings.Count(string(res[0].data), "map $http_host $gw_api_compliant_host {")).To(Equal(1))
5151
g.Expect(strings.Count(string(res[0].data), "map $http_upgrade $connection_upgrade {")).To(Equal(1))
52+
g.Expect(strings.Count(string(res[0].data), "map $request_uri $request_uri_path {")).To(Equal(1))
5253
}
5354
}

internal/mode/static/nginx/config/maps_template.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,4 @@ map {{ $m.Source }} {{ $m.Variable }} {
1111
{{ end }}
1212
}
1313
{{- end }}
14-
15-
# Set $gw_api_compliant_host variable to the value of $http_host unless $http_host is empty, then set it to the value
16-
# of $host. We prefer $http_host because it contains the original value of the host header, which is required by the
17-
# Gateway API. However, in an HTTP/1.0 request, it's possible that $http_host can be empty. In this case, we will use
18-
# the value of $host. See http://nginx.org/en/docs/http/ngx_http_core_module.html#var_host.
19-
map $http_host $gw_api_compliant_host {
20-
'' $host;
21-
default $http_host;
22-
}
23-
24-
# Set $connection_header variable to upgrade when the $http_upgrade header is set, otherwise, set it to close. This
25-
# allows support for websocket connections. See https://nginx.org/en/docs/http/websocket.html.
26-
map $http_upgrade $connection_upgrade {
27-
default upgrade;
28-
'' close;
29-
}
30-
31-
## Returns just the path from the original request URI.
32-
map $request_uri $request_uri_path {
33-
"~^(?P<path>[^?]*)(\?.*)?$" $path;
34-
}
3514
`

internal/mode/static/nginx/config/maps_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ func TestExecuteMaps(t *testing.T) {
8585
"map ${http_my_second_add_header} $my_second_add_header_header_var {": 1,
8686
"~.* ${http_my_second_add_header},;": 1,
8787
"map ${http_my_set_header} $my_set_header_header_var {": 0,
88-
"map $http_host $gw_api_compliant_host {": 1,
89-
"map $http_upgrade $connection_upgrade {": 1,
90-
"map $request_uri $request_uri_path {": 1,
9188
}
9289

9390
mapResult := executeMaps(conf)

internal/mode/static/state/dataplane/configuration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,6 +3285,7 @@ func TestCreateRatioVarName(t *testing.T) {
32853285
g := NewWithT(t)
32863286
g.Expect(CreateRatioVarName(25)).To(Equal("$otel_ratio_25"))
32873287
}
3288+
32883289
func TestCreatePassthroughServers(t *testing.T) {
32893290
getL4RouteKey := func(name string) graph.L4RouteKey {
32903291
return graph.L4RouteKey{

0 commit comments

Comments
 (0)