At my company we have a pattern of passing in parent context into our http handlers. Currently we are passing in parentContext into methods in the handler that need them db.Query(parentCtx...)
.
My question is should we be using the gin Context or the gin Request context here instead.
CodePudding user response:
If you want to terminate processing if the connection is closed, use the Request.Context
. Based on the documentation for Done
:
Done always returns nil (chan which will wait forever), if you want to abort your work when the connection was closed you should use Request.Context().Done() instead.