Trim tailing slash from service name before proxy

**What**
- When determining the service name of the function, remove any trailing
slashes, the slashes are not allowed in service names for either Swarm
or K8S, so this can only be a left over from the url path

**Why**
- This was preventing service resolution, and hence failed functions,
    when the function was called with a trailing slash

Fixes #714

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
This commit is contained in:
Lucas Roesler
2018-06-07 00:05:00 +02:00
committed by Alex Ellis
parent 1f6e174454
commit 6676d1b807
2 changed files with 51 additions and 2 deletions

View File

@ -133,7 +133,7 @@ func getServiceName(urlValue string) string {
if strings.HasPrefix(urlValue, forward) {
serviceName = urlValue[len(forward):]
}
return serviceName
return strings.Trim(serviceName, "/")
}
// LoggingNotifier notifies a log about a request
@ -168,7 +168,6 @@ type FunctionAsHostBaseURLResolver struct {
// Resolve the base URL for a request
func (f FunctionAsHostBaseURLResolver) Resolve(r *http.Request) string {
svcName := getServiceName(r.URL.Path)
const watchdogPort = 8080