Retrieve URL params in functions (#226)

Addresses #158. Adds URL params into HTTP headers. A URL param named `KEY` with the value `VALUE` in the actual URL will appear as the header "X-Fission-Params-KEY: VALUE" in the fission function.
This commit is contained in:
yang qf
2017-06-17 21:12:12 -07:00
committed by Soam Vasani
parent c1dd8a9f35
commit b1e66663bd
+8
View File
@@ -25,6 +25,8 @@ import (
"net/url"
"time"
"github.com/gorilla/mux"
"github.com/fission/fission"
poolmgrClient "github.com/fission/fission/poolmgr/client"
)
@@ -90,6 +92,12 @@ func (fh *functionHandler) tapService(serviceUrl *url.URL) {
func (fh *functionHandler) handler(responseWriter http.ResponseWriter, request *http.Request) {
reqStartTime := time.Now()
// retrieve url params and add them to request header
vars := mux.Vars(request)
for k, v := range vars {
request.Header.Add(fmt.Sprintf("X-Fission-Params-%v", k), v)
}
// cache lookup
serviceUrl, err := fh.fmap.lookup(&fh.Function)
if err != nil {