reprogl
22 строки · 442.0 Байт
1package middlewares2
3import (4"errors"5"fmt"6"net/http"7
8"xelbot.com/reprogl/container"9)
10
11func Recover(next http.Handler, app *container.Application) http.Handler {12return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {13defer func() {14if rvr := recover(); rvr != nil && rvr != http.ErrAbortHandler {15err := errors.New(fmt.Sprintf("%v", rvr))16app.ServerError(w, err)17}18}()19
20next.ServeHTTP(w, r)21})22}
23