Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
fastcgi: Make EnvVars a map instead of a slice
Matthew Holt committed
Sep 10, 2019 at 14:12 UTC
c32b7e8865224b124a9be999317f87d45e2b2a48
2 files changed
+8
-5
modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
+4
-1
@@ -44,7 +44,10 @@ func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
44
if len(args) != 2 {
45
return d.ArgErr()
46
}
47
- t.EnvVars = append(t.EnvVars, [2]string{args[0], args[1]})
47
+ if t.EnvVars == nil {
48
+ t.EnvVars = make(map[string]string)
49
+ }
50
+ t.EnvVars[args[0]] = args[1]
51
52
default:
53
return d.Errf("unrecognized subdirective %s", d.Val())
modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+4
-4
@@ -55,8 +55,8 @@ type Transport struct {
55
// PATH_INFO for the CGI script to use.
56
SplitPath string `json:"split_path,omitempty"`
57
58
- // Environment variables (TODO: make a map of string to value...?)
59
- EnvVars [][2]string `json:"env,omitempty"`
58
+ // Extra environment variables
59
+ EnvVars map[string]string `json:"env,omitempty"`
60
61
// The duration used to set a deadline when connecting to an upstream.
62
DialTimeout caddy.Duration `json:"dial_timeout,omitempty"`
@@ -259,8 +259,8 @@ func (t Transport) buildEnv(r *http.Request) (map[string]string, error) {
259
}
260
261
// Add env variables from config (with support for placeholders in values)
262
- for _, envVar := range t.EnvVars {
263
- env[envVar[0]] = repl.ReplaceAll(envVar[1], "")
262
+ for key, value := range t.EnvVars {
263
+ env[key] = repl.ReplaceAll(value, "")
264
}
265
266
// Add all HTTP headers to env variables