diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2023-10-24 08:38:40 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2023-10-24 08:38:40 +0200 |
| commit | a9927763f43d59c418b264790ccee59defe8ca29 (patch) | |
| tree | 5dfc4f1f1f29d1ef1cbca3406bf57d1667b93f76 /core/middleware.go | |
| parent | ed23d402fec268e163ec895748f43e3254ba3dfd (diff) | |
refactor: Rename packages for clarityv0.3.0
Diffstat (limited to 'core/middleware.go')
| -rw-r--r-- | core/middleware.go | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/core/middleware.go b/core/middleware.go deleted file mode 100644 index 55e67fb..0000000 --- a/core/middleware.go +++ /dev/null @@ -1,31 +0,0 @@ -package core - -import ( - "errors" - "net/http" - - "golang.org/x/exp/slog" -) - -func RecoverMiddleware(next http.Handler) http.Handler { - fn := func(w http.ResponseWriter, r *http.Request) { - defer func() { - if rcv := recover(); rcv != nil { - switch err := rcv.(type) { - case error: - if errors.Is(err, http.ErrAbortHandler) { - panic(rcv) - } - slog.Error(err.Error()) - http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) - default: - panic(err) - } - } - }() - - next.ServeHTTP(w, r) - } - - return http.HandlerFunc(fn) -} |
