Skip to content

Commit f73e994

Browse files
authored
Fix whitespace in nginx templates (#597)
The nginx templates were hard to read due to excessive whitespacing in the templates. It's not perfect, but these changes should clean things up quite a bit.
1 parent 6befb1d commit f73e994

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

internal/nginx/config/servers_template.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
package config
22

33
var serversTemplateText = `
4-
{{ range $s := . }}
5-
{{ if $s.IsDefaultSSL }}
4+
{{ range $s := . -}}
5+
{{ if $s.IsDefaultSSL -}}
66
server {
77
listen 443 ssl default_server;
88
99
ssl_reject_handshake on;
1010
}
11-
{{ else if $s.IsDefaultHTTP }}
11+
{{- else if $s.IsDefaultHTTP }}
1212
server {
1313
listen 80 default_server;
1414
1515
default_type text/html;
1616
return 404;
1717
}
18-
{{ else }}
18+
{{- else }}
1919
server {
20-
{{ if $s.SSL }}
20+
{{- if $s.SSL }}
2121
listen 443 ssl;
2222
ssl_certificate {{ $s.SSL.Certificate }};
2323
ssl_certificate_key {{ $s.SSL.CertificateKey }};
2424
2525
if ($ssl_server_name != $host) {
2626
return 421;
2727
}
28-
{{ end }}
28+
{{- end }}
2929
3030
server_name {{ $s.ServerName }};
3131
3232
{{ range $l := $s.Locations }}
3333
location {{ $l.Path }} {
34-
{{ if $l.Internal }}
34+
{{ if $l.Internal -}}
3535
internal;
3636
{{ end }}
3737
38-
{{ if $l.Return }}
38+
{{- if $l.Return -}}
3939
return {{ $l.Return.Code }} "{{ $l.Return.Body }}";
4040
{{ end }}
4141
42-
{{ if $l.HTTPMatchVar }}
42+
{{- if $l.HTTPMatchVar -}}
4343
set $http_matches {{ $l.HTTPMatchVar | printf "%q" }};
4444
js_content httpmatches.redirect;
4545
{{ end }}
4646
47-
{{ if $l.ProxyPass }}
47+
{{- if $l.ProxyPass -}}
4848
proxy_set_header Host $host;
4949
proxy_pass {{ $l.ProxyPass }}$request_uri;
50-
{{ end }}
50+
{{- end }}
5151
}
5252
{{ end }}
5353
}
54-
{{ end }}
54+
{{- end }}
5555
{{ end }}
5656
server {
5757
listen unix:/var/lib/nginx/nginx-502-server.sock;

internal/nginx/config/split_clients_template.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package config
33
var splitClientsTemplateText = `
44
{{ range $sc := . }}
55
split_clients $request_id ${{ $sc.VariableName }} {
6-
{{ range $d := $sc.Distributions }}
7-
{{ if eq $d.Percent "0.00" }}
6+
{{- range $d := $sc.Distributions }}
7+
{{- if eq $d.Percent "0.00" }}
88
# {{ $d.Percent }}% {{ $d.Value }};
9-
{{ else }}
9+
{{- else }}
1010
{{ $d.Percent }}% {{ $d.Value }};
11-
{{ end }}
12-
{{ end }}
11+
{{- end }}
12+
{{- end }}
1313
}
14-
{{ end }}`
14+
{{ end }}
15+
`

internal/nginx/config/upstreams_template.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ upstream {{ $u.Name }} {
88
random two least_conn;
99
{{ range $server := $u.Servers }}
1010
server {{ $server.Address }};
11-
{{ end }}
11+
{{- end }}
1212
}
13-
{{ end }}`
13+
{{ end }}
14+
`

0 commit comments

Comments
 (0)