From 1b76cdf200faeb03f166e63997c1b1438a9a8e6d Mon Sep 17 00:00:00 2001 From: Soam Vasani Date: Thu, 3 Nov 2016 10:11:43 -0700 Subject: [PATCH] Remove request path when routing Route all requests to / on the function run container. It doesn't need to do any routing since it has only one function. --- router/functionHandler.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/router/functionHandler.go b/router/functionHandler.go index e134ddf6..d6e6b548 100644 --- a/router/functionHandler.go +++ b/router/functionHandler.go @@ -71,12 +71,18 @@ func (fh *functionHandler) handler(responseWriter http.ResponseWriter, request * // TODO: As an optimization we may want to cache proxies too -- this might get us // connection reuse and possibly better performance director := func(req *http.Request) { - log.Printf("Proxying request for %v", req.URL) + log.Printf("Proxying request for %v to %v", req.URL, serviceUrl.Host) // send this request to serviceurl req.URL.Scheme = serviceUrl.Scheme req.URL.Host = serviceUrl.Host - req.URL.Path = serviceUrl.Path + + // To keep the function run container simple, it + // doesn't do any routing. In the future if we have + // multiple functions per container, we could use the + // function metadata here. + req.URL.Path = "/" + // leave the query string intact (req.URL.RawQuery) if _, ok := req.Header["User-Agent"]; !ok {