Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
9e3852f2
Commit
9e3852f2
authored
May 01, 2015
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #34 from abiosoft/master
fastcgi: user defined environment variables
parents
49bb3f13
447d0ce0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+14
-0
No files found.
middleware/fastcgi/fastcgi.go
View file @
9e3852f2
...
...
@@ -200,6 +200,11 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, path string) (map[string]s
"SCRIPT_NAME"
:
scriptName
,
}
// Add env variables from config
for
_
,
envVar
:=
range
rule
.
EnvVars
{
env
[
envVar
[
0
]]
=
envVar
[
1
]
}
// Add all HTTP headers to env variables
for
field
,
val
:=
range
r
.
Header
{
header
:=
strings
.
ToUpper
(
field
)
...
...
@@ -253,6 +258,12 @@ func parse(c middleware.Controller) ([]Rule, error) {
return
rules
,
c
.
ArgErr
()
}
rule
.
IndexFile
=
c
.
Val
()
case
"env"
:
envArgs
:=
c
.
RemainingArgs
()
if
len
(
envArgs
)
<
2
{
return
rules
,
c
.
ArgErr
()
}
rule
.
EnvVars
=
append
(
rule
.
EnvVars
,
[
2
]
string
{
envArgs
[
0
],
envArgs
[
1
]})
}
}
...
...
@@ -295,6 +306,9 @@ type Rule struct {
// If the URL does not indicate a file, an index file with this name will be assumed.
IndexFile
string
// Environment Variables
EnvVars
[][
2
]
string
}
var
headerNameReplacer
=
strings
.
NewReplacer
(
" "
,
"_"
,
"-"
,
"_"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment