mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-25 14:08:09 +02:00
controlplane: remove gorilla handlers dependency (#3813)
This commit is contained in:
parent
b375dc4896
commit
27c94396a8
4 changed files with 21 additions and 9 deletions
19
internal/middleware/recovery.go
Normal file
19
internal/middleware/recovery.go
Normal 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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue