mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Merge pull request #294 from fnproject/fixDefaultHeadersMissing
Add headers to env for default functions
This commit is contained in:
@@ -103,12 +103,22 @@ func FromRequest(appName, path string, req *http.Request) CallOpt {
|
|||||||
envVars[toEnvName("PARAM", param.Key)] = param.Value
|
envVars[toEnvName("PARAM", param.Key)] = param.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headerVars := make(map[string]string,len(req.Header))
|
||||||
|
|
||||||
|
for k, v := range req.Header {
|
||||||
|
headerVars[toEnvName("HEADER",k)] = strings.Join(v, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
// add all the env vars we build to the request headers
|
// add all the env vars we build to the request headers
|
||||||
// TODO should we save req.Headers and copy OVER app.Config / route.Config ?
|
// TODO should we save req.Headers and copy OVER app.Config / route.Config ?
|
||||||
for k, v := range envVars {
|
for k, v := range envVars {
|
||||||
req.Header.Add(k, v)
|
req.Header.Add(k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for k,v := range headerVars {
|
||||||
|
envVars[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
// TODO this relies on ordering of opts, but tests make sure it works, probably re-plumb/destroy headers
|
// TODO this relies on ordering of opts, but tests make sure it works, probably re-plumb/destroy headers
|
||||||
if rw, ok := c.w.(http.ResponseWriter); ok {
|
if rw, ok := c.w.(http.ResponseWriter); ok {
|
||||||
rw.Header().Add("FN_CALL_ID", id)
|
rw.Header().Add("FN_CALL_ID", id)
|
||||||
|
|||||||
Reference in New Issue
Block a user