From 0a0bb40245d88c9460915849200ec38a830b9976 Mon Sep 17 00:00:00 2001 From: cpda11 <53509553+cpda11@users.noreply.github.com> Date: Sat, 4 Dec 2021 13:47:11 +0100 Subject: [PATCH] Cleanup --- internal/proxy/handler.go | 23 ++++------------------- internal/proxy/types.go | 2 +- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/internal/proxy/handler.go b/internal/proxy/handler.go index c244e91..9bb7c78 100644 --- a/internal/proxy/handler.go +++ b/internal/proxy/handler.go @@ -50,9 +50,6 @@ var ( func (br *BackendRequest) configureBackendRequest(req *http.Request) error { var err error br.Method = strings.ToUpper(req.Header.Get("method")) - if br.Method == "" { - br.Method = "GET" - } br.URI, err = url.Parse(req.Header.Get("uri")) if err != nil { return err @@ -92,24 +89,12 @@ func (br *BackendRequest) requestBackend() (*BackendResponse, error) { return nil, errors.New("Error parsing body: " + err.Error()) } - if res.StatusCode != 0 { - backendResponse.StatusCode = res.StatusCode - } - if res.Request != nil { - if res.Request.RequestURI != "" { - backendResponse.URI = res.Request.RequestURI - } - } - - if res.Header != nil { - backendResponse.Headers = &res.Header - } - - responseBody := string(backendHttpResponseBytes) - if responseBody != "" { - backendResponse.Body = responseBody + backendResponse.URI = res.Request.RequestURI } + backendResponse.StatusCode = res.StatusCode + backendResponse.Headers = res.Header + backendResponse.Body = string(backendHttpResponseBytes) return backendResponse, nil } diff --git a/internal/proxy/types.go b/internal/proxy/types.go index b686017..1a69af6 100644 --- a/internal/proxy/types.go +++ b/internal/proxy/types.go @@ -15,6 +15,6 @@ type BackendRequest struct { type BackendResponse struct { StatusCode int URI string - Headers *http.Header + Headers http.Header Body string }