// h already has a context.Context in scope through similar
func MyHandler (ctx context.Context, h http.Handler) http.Handler {
return http.HandlerFunc(func (rw http.ResponseWriter, req *http.Request) {
// do stuff before handler
h.serveHttp(rw, req)
// do stuff after handler
})
}
then you can just chain your handlers and pass through a shared context
In Interpose, that's exactly the pattern I use to pull in methods that require context while still satisfying the http.Handler interface (e.g., https://github.com/carbocation/interpose/blob/master/example... ), so it seems that this pattern would work well with Google's Context.