summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/fastcgi
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-10 14:12:51 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-10 14:12:51 -0600
commitc32b7e8865224b124a9be999317f87d45e2b2a48 (patch)
tree71bb46036b12ee048fac847672f98c4e4b89f2c3 /modules/caddyhttp/reverseproxy/fastcgi
parent1ce10b453fbfd01aae7887c4ff8e5730f7908f50 (diff)
fastcgi: Make EnvVars a map instead of a slice
Diffstat (limited to 'modules/caddyhttp/reverseproxy/fastcgi')
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go5
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go8
2 files changed, 8 insertions, 5 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
index c8b9f63..6fa63be 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
@@ -44,7 +44,10 @@ func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if len(args) != 2 {
return d.ArgErr()
}
- t.EnvVars = append(t.EnvVars, [2]string{args[0], args[1]})
+ if t.EnvVars == nil {
+ t.EnvVars = make(map[string]string)
+ }
+ t.EnvVars[args[0]] = args[1]
default:
return d.Errf("unrecognized subdirective %s", d.Val())
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
index 91039c9..9df6585 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
@@ -55,8 +55,8 @@ type Transport struct {
// PATH_INFO for the CGI script to use.
SplitPath string `json:"split_path,omitempty"`
- // Environment variables (TODO: make a map of string to value...?)
- EnvVars [][2]string `json:"env,omitempty"`
+ // Extra environment variables
+ EnvVars map[string]string `json:"env,omitempty"`
// The duration used to set a deadline when connecting to an upstream.
DialTimeout caddy.Duration `json:"dial_timeout,omitempty"`
@@ -259,8 +259,8 @@ func (t Transport) buildEnv(r *http.Request) (map[string]string, error) {
}
// Add env variables from config (with support for placeholders in values)
- for _, envVar := range t.EnvVars {
- env[envVar[0]] = repl.ReplaceAll(envVar[1], "")
+ for key, value := range t.EnvVars {
+ env[key] = repl.ReplaceAll(value, "")
}
// Add all HTTP headers to env variables