Skip to content
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

Close the request body with a middleware instead of within the handler function body #85

Open
tiagoalvesdulce opened this issue Nov 17, 2022 · 0 comments

Comments

@tiagoalvesdulce
Copy link
Member

As mentioned by Luke here: #84 (comment).

We already have the middleware defined here:

func closeBody(f http.HandlerFunc) http.HandlerFunc {

And are using it here:

func (d *DcrtimeStore) addRoute(method string, route string, handler http.HandlerFunc) {

As we add every route with the addRoute method. It should be already working so the calls to defer r.Body.Close inside handler functions are redundant and can be removed.

@tiagoalvesdulce tiagoalvesdulce changed the title Close the request body with a middleware instead of the handler function body Close the request body with a middleware instead of within the handler function body Nov 17, 2022
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

No branches or pull requests

1 participant