Enable prefix based routing (#2047)

* Enable prefix based routing

Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>

* Optimize checking condition

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Disable few tests

* disable router modification for now

* run code generator

* Collect fission dump in CI

* Enable all tests back

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Remove unwanted code

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Add prefix support at more places and couple of todo's

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Few more changes

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Improve function trim support

* Support for prefix based urls in fission function test

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* multi route for fission function test

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Improve validations in trigger creations

* Adjust leading / in url from fission

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

* Change suburl to subpath for function test

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>

Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Harsh Thakur
2021-06-10 13:54:49 +05:30
committed by GitHub
co-authored by Sanket Sudake
parent f01de5c802
commit aa45703a99
20 changed files with 149 additions and 44 deletions
+8 -3
View File
@@ -166,13 +166,18 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
fh.function = fn
}
}
var ht *mux.Route
ht := muxRouter.HandleFunc(trigger.Spec.RelativeURL, fh.handler)
if trigger.Spec.Prefix != nil && *trigger.Spec.Prefix != "" {
ht = muxRouter.PathPrefix(*trigger.Spec.Prefix).HandlerFunc(fh.handler)
} else {
ht = muxRouter.HandleFunc(trigger.Spec.RelativeURL, fh.handler)
}
ht.Methods(trigger.Spec.Method)
if trigger.Spec.Host != "" {
ht.Host(trigger.Spec.Host)
}
if trigger.Spec.RelativeURL == "/" && trigger.Spec.Method == "GET" {
if trigger.Spec.Prefix == nil && trigger.Spec.RelativeURL == "/" && trigger.Spec.Method == "GET" {
homeHandled = true
}
}
@@ -202,7 +207,7 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
functionTimeoutMap: fnTimeoutMap,
unTapServiceTimeout: ts.unTapServiceTimeout,
}
muxRouter.HandleFunc(utils.UrlForFunction(fn.ObjectMeta.Name, fn.ObjectMeta.Namespace), fh.handler)
muxRouter.PathPrefix(utils.UrlForFunction(fn.ObjectMeta.Name, fn.ObjectMeta.Namespace)).HandlerFunc(fh.handler)
}
// Healthz endpoint for the router.