From b1e66663bd9af41bf7ee00ac5c66044bf541f634 Mon Sep 17 00:00:00 2001 From: yang qf Date: Sat, 17 Jun 2017 23:12:12 -0500 Subject: [PATCH] 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. --- router/functionHandler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/router/functionHandler.go b/router/functionHandler.go index 63f1b0f0..0b32a441 100644 --- a/router/functionHandler.go +++ b/router/functionHandler.go @@ -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 {