package main import ( "git.fuyu.moe/Fuyu/flog" "github.com/labstack/echo" ) func recoverMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { defer func() { v := recover() if v != nil { flog.Critical(`panic: `, v) _ = c.JSON(500, `Fatal error occurred`) } }() return next(c) } }