mirror of
https://github.com/openfaas/faas.git
synced 2025-06-08 16:26:47 +00:00
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:
parent
b786104f3a
commit
c67c9f2b30
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user