Fix issue with direct_functions and path behaviour

- The path clipping / transforming behaviour must be turned-off
when we are not using direct_functions as is used in
faas-nomad and faas-ecs. This will need a change in each provider
to strip paths, but fixes a 404 error these users will see if they
upgrade to 0.9.2 or newer. 0.9.3 will have a this fix meaning
the whole un-edited path is passed to the provider when
direct_functions is set to false.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware) 2018-09-15 14:40:22 +01:00
parent b786104f3a
commit c67c9f2b30
2 changed files with 9 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import (
"io"
"log"
"net/http"
"os"
"regexp"
"strconv"
"strings"
@ -100,6 +101,10 @@ func forwardRequest(w http.ResponseWriter, r *http.Request, proxyClient *http.Cl
defer upstreamReq.Body.Close()
}
if _, exists := os.LookupEnv("write_request_uri"); exists {
log.Printf("forwardRequest: %s %s\n", upstreamReq.Host, upstreamReq.URL.String())
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

View File

@ -68,16 +68,17 @@ func main() {
urlResolver := handlers.SingleHostBaseURLResolver{BaseURL: config.FunctionsProviderURL.String()}
var functionURLResolver handlers.BaseURLResolver
var functionURLTransformer handlers.URLPathTransformer
nilURLTransformer := handlers.TransparentURLPathTransformer{}
if config.DirectFunctions {
functionURLResolver = handlers.FunctionAsHostBaseURLResolver{FunctionSuffix: config.DirectFunctionsSuffix}
functionURLTransformer = handlers.FunctionPrefixTrimmingURLPathTransformer{}
} else {
functionURLResolver = urlResolver
functionURLTransformer = nilURLTransformer
}
nilURLTransformer := handlers.TransparentURLPathTransformer{}
functionURLTransformer := handlers.FunctionPrefixTrimmingURLPathTransformer{}
faasHandlers.Proxy = handlers.MakeForwardingProxyHandler(reverseProxy, functionNotifiers, functionURLResolver, functionURLTransformer)
faasHandlers.RoutelessProxy = handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver, nilURLTransformer)