package ginext import ( "bringman.de/common/shared/bmerror" "context" "github.com/gin-gonic/gin" "net/http" ) func NewEngine() *gin.Engine { engine := gin.New() engine.RedirectFixedPath = false engine.RedirectTrailingSlash = false engine.Use(gin.CustomRecovery(func(c *gin.Context, err interface{}) { ctx := context.Background() bmerror. New(bmerror.ErrGinPanic, "gin request caused panic"). Interface("panic-object", err). Stack(). GinReq(ctx, c, c.Request). WithStatuscode(http.StatusInternalServerError). Output(ctx, c) })) return engine } func NoRouteHandler() func(c *gin.Context) { return func(g *gin.Context) { bmerror.New(bmerror.ErrRouteNotFound, "Route not found"). Str("FullPath", g.FullPath()). Str("Method", g.Request.Method). Str("URL", g.Request.URL.String()). Str("RequestURI", g.Request.RequestURI). Str("Proto", g.Request.Proto). Any("Header", g.Request.Header). Output(context.Background(), g) } }