3 ms·
We created a custom implementation of an io.ReadCloser that allowed us to wrap the http.Handler's io.ReadCloser and attach context to the request: https://githu
by bradrydzewski 13y ago
We created a custom implementation of an io.ReadCloser that allowed us to wrap the http.Handler's io.ReadCloser and attach context to the request:
https://github.com/bradrydzewski/routes/blob/master/exp/context/context.go https://github.com/bradrydzewski/routes/blob/master/exp/cont...
It avoids the global lock and we haven't found any compatibility issues.
- optymizer1 13y agoThis is pretty neat. Functions that read from or write to http.Request.Body should be able to accept a Context object, assuming they take a Reader/Writer. If they take an http.Request, you're going to pass in Context.req, similar to how custom.Request would contain a custom.req field.