Skip to content

#98 Bug/incorrect response code for empty body #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jschulte-maxmine
Copy link

This resolves an issue where if the route is not found the gzip lib returns 200 status code if nothing writes to the body.

I considered a couple of approaches:

  • Conditionally write the headers during the defer, this overrides the default Gin behaviour which is not desirable
    • This has a bunch of edge cases like if another middleware is doing something with 404 bodies
  • Conditionally ignore the gzip middleware on 404 status codes or set to do not compress
    • If there is response content by another middleware theres no reason why we can't compress it
  • Conditionally replace the gzip writer with the original gin writer if it hasn't already been used
  • Seemed to be the most sensible if we are not going to use the gzip writer we can just put the gin writer back in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant