I just read this blog post about creating a function type and implementing the .ServeHTTP() method on that function to be able to handle errors. For example:
.ServeHTTP()
Use r.Context(), which is available since Go 1.7.
r.Context()
See https://golang.org/pkg/net/http/#Request.Context