A única outra solução que vi, por exemplo, em "Passing Context to Interface Methods" é:
crie umastructque aceita um contexto incorporado e nossohandlertipo, e ainda satisfazemos ohttp.Handlerinterface graças aServeHTTP.
No seu caso, a
struct incluiria o pool , e o handler função. type appContext struct {
pool Pool
}
type appHandler struct {
*appContext
h func(a *appContext, w http.ResponseWriter, r *http.Request) (int, error)
}
func (ah appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
}
func main() {
context := &appContext{
pool: ...,
// any other data
}
}