middlewares

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RecoverMiddleware = func(log *logrus.Logger) echo.MiddlewareFunc {
	return middleware.RecoverWithConfig(
		middleware.RecoverConfig{
			LogErrorFunc: func(c echo.Context, err error, stack []byte) error {
				log.WithFields(logrus.Fields{
					"error":  err.Error(),
					"stack":  string(stack),
					"URI":    c.Request().RequestURI,
					"method": c.Request().Method,
					"status": c.Response().Status,
					"type":   "recovery",
				}).Error("recovery")
				return c.String(http.StatusInternalServerError, "Internal Server Error")
			},
		})
}

RecoverMiddleware is the middleware that recovers from panics and logs the error It returns a middleware function that can be used to register the middleware It uses the provided logger to log the error

Functions

func AccessLogMiddleware

func AccessLogMiddleware(log *logrus.Logger) echo.MiddlewareFunc

AccessLogMiddleware is the middleware that logs the access log It returns a middleware function that can be used to register the middleware It uses the provided logger to log the access log

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL