Improved layout middleware

This commit is contained in:
2019-06-03 14:53:04 +09:00
parent 3268488b7b
commit cf68184c46
6 changed files with 24 additions and 18 deletions

View File

@ -3,7 +3,9 @@ package middleware
import (
"fmt"
"net/http"
"os"
"runtime"
"strings"
"github.com/aerogo/aero"
)
@ -26,7 +28,11 @@ func Recover(next aero.Handler) aero.Handler {
stack := make([]byte, 4096)
length := runtime.Stack(stack, true)
_ = ctx.Error(http.StatusInternalServerError, err, stack[:length])
stackString := string(stack[:length])
fmt.Fprint(os.Stderr, stackString)
message := err.Error() + "<br><br>" + strings.ReplaceAll(stackString, "\n", "<br>")
_ = ctx.Error(http.StatusInternalServerError, message)
}()
return next(ctx)