controlplane: remove gorilla handlers dependency (#3813)

This commit is contained in:
Caleb Doxsey 2022-12-15 14:41:29 -07:00 committed by GitHub
parent b375dc4896
commit 27c94396a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 9 deletions

View file

@ -0,0 +1,19 @@
package middleware
import (
"net/http"
"github.com/pomerium/pomerium/internal/log"
)
// Recovery is an HTTP middleware function that logs any panics.
func Recovery(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
log.Error(r.Context()).Interface("error", err).Msg("middleware: panic while serving http")
}
}()
next.ServeHTTP(w, r)
})
}