mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 14:13:48 +03:00
fastcgi: Make EnvVars a map instead of a slice
This commit is contained in:
parent
1ce10b453f
commit
c32b7e8865
2 changed files with 8 additions and 5 deletions
|
@ -44,7 +44,10 @@ func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
return d.ArgErr()
|
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:
|
default:
|
||||||
return d.Errf("unrecognized subdirective %s", d.Val())
|
return d.Errf("unrecognized subdirective %s", d.Val())
|
||||||
|
|
|
@ -55,8 +55,8 @@ type Transport struct {
|
||||||
// PATH_INFO for the CGI script to use.
|
// PATH_INFO for the CGI script to use.
|
||||||
SplitPath string `json:"split_path,omitempty"`
|
SplitPath string `json:"split_path,omitempty"`
|
||||||
|
|
||||||
// Environment variables (TODO: make a map of string to value...?)
|
// Extra environment variables
|
||||||
EnvVars [][2]string `json:"env,omitempty"`
|
EnvVars map[string]string `json:"env,omitempty"`
|
||||||
|
|
||||||
// The duration used to set a deadline when connecting to an upstream.
|
// The duration used to set a deadline when connecting to an upstream.
|
||||||
DialTimeout caddy.Duration `json:"dial_timeout,omitempty"`
|
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)
|
// Add env variables from config (with support for placeholders in values)
|
||||||
for _, envVar := range t.EnvVars {
|
for key, value := range t.EnvVars {
|
||||||
env[envVar[0]] = repl.ReplaceAll(envVar[1], "")
|
env[key] = repl.ReplaceAll(value, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all HTTP headers to env variables
|
// Add all HTTP headers to env variables
|
||||||
|
|
Loading…
Reference in a new issue