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:
@@ -25,6 +25,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
"github.com/fission/fission"
|
"github.com/fission/fission"
|
||||||
poolmgrClient "github.com/fission/fission/poolmgr/client"
|
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) {
|
func (fh *functionHandler) handler(responseWriter http.ResponseWriter, request *http.Request) {
|
||||||
reqStartTime := time.Now()
|
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
|
// cache lookup
|
||||||
serviceUrl, err := fh.fmap.lookup(&fh.Function)
|
serviceUrl, err := fh.fmap.lookup(&fh.Function)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user