Skip to content

Commit

Permalink
Merge pull request #5 from thnxdev/http-response-headers
Browse files Browse the repository at this point in the history
Copy http.Response type headers correctly
  • Loading branch information
nehzata authored Jan 25, 2024
2 parents 12a6ee0 + 8861c2b commit bfe2286
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/happy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ func generateHandler(gctx *genContext, eps []endpoint, tree *tree) error {
w.L(" w.Header().Set(\"Content-Type\", \"application/octet-stream\")")
w.L(" w.Write(res)")
w.L("case *http.Response:")
w.L(" headers := w.Header()")
w.L(" for k, v := range res.Header {")
w.L(" headers[k] = v")
w.L(" w.Header().Set(k, strings.Join(v, \"; \"))")
w.L(" }")
w.L(" w.WriteHeader(res.StatusCode)")
w.L(" _, _ = io.Copy(w, res.Body)")
Expand Down

0 comments on commit bfe2286

Please sign in to comment.