mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add headers to env for default functions
This commit is contained in:
@@ -103,12 +103,24 @@ func FromRequest(appName, path string, req *http.Request) CallOpt {
|
||||
envVars[toEnvName("PARAM", param.Key)] = param.Value
|
||||
}
|
||||
|
||||
var headerVars = make(map[string]string)
|
||||
for k, v := range req.Header {
|
||||
joinedHeader := strings.Join(v,",")
|
||||
headerVars[toEnvName("HEADER",k)] = joinedHeader
|
||||
}
|
||||
|
||||
// add all the env vars we build to the request headers
|
||||
// TODO should we save req.Headers and copy OVER app.Config / route.Config ?
|
||||
for k, v := range envVars {
|
||||
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
|
||||
if rw, ok := c.w.(http.ResponseWriter); ok {
|
||||
rw.Header().Add("FN_CALL_ID", id)
|
||||
|
||||
Reference in New Issue
Block a user