dcrtime icon indicating copy to clipboard operation
dcrtime copied to clipboard

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

Open tiagoalvesdulce opened this issue 2 years ago • 0 comments

As mentioned by Luke here: https://github.com/decred/dcrtime/pull/84#discussion_r1021757335.

We already have the middleware defined here: https://github.com/decred/dcrtime/blob/bbebe6df45a8c650c4e605d778494480b056f121/dcrtimed/dcrtimed.go#L1297

And are using it here: https://github.com/decred/dcrtime/blob/bbebe6df45a8c650c4e605d778494480b056f121/dcrtimed/dcrtimed.go#L1306

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 avatar Nov 17 '22 15:11 tiagoalvesdulce