Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cpda11 committed Dec 4, 2021
1 parent 56e43c1 commit 0a0bb40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
23 changes: 4 additions & 19 deletions internal/proxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion internal/proxy/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ type BackendRequest struct {
type BackendResponse struct {
StatusCode int
URI string
Headers *http.Header
Headers http.Header
Body string
}

0 comments on commit 0a0bb40

Please sign in to comment.