openfaas / of-watchdog

Reverse proxy for STDIO and HTTP microservices
MIT License
259 stars 115 forks source link

HTTP mode - Pass QueryString along to upstream_url #18

Closed alexellis closed 6 years ago

alexellis commented 6 years ago

Expected Behaviour

QueryString should be available in the function when using HTTP mode

Current Behaviour

The QueryString is not forwarded or consumed by templates

Possible Solution

diff --git a/executor/http_runner.go b/executor/http_runner.go
index c73d5cf..fa15cf4 100644--- a/executor/http_runner.go
+++ b/executor/http_runner.go
@@ -96,7 +96,13 @@ func (f *HTTPFunctionRunner) Start() error {
 // Run a function with a long-running process with a HTTP protocol for communication func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *http.Request, w http.ResponseWriter) error{

-       request, _ := http.NewRequest(r.Method, f.UpstreamURL.String(), r.Body)
+       upstreamURL := f.UpstreamURL.String()
+
+       if len(r.URL.RawQuery) > 0 {
+               upstreamURL += "?" + r.URL.RawQuery
+       }
+
+       request, _ := http.NewRequest(r.Method, upstreamURL,r.Body)
        for h := range r.Header {
                request.Header.Set(h, r.Header.Get(h))
        }