middlewaretools

package
v1.0.1-0...-984eda3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderUserID = "X-User-Id"

Variables

View Source
var (
	FilterPasswordFunc = func(s []byte) []byte {
		return passwordReg.ReplaceAll(s, []byte(`$1"*******"`))
	}
	BodyDumpMiddleware = func(filterRequestFuncs ...func([]byte) []byte) echo.MiddlewareFunc {
		return middleware.BodyDumpWithConfig(middleware.BodyDumpConfig{
			Handler: func(c echo.Context, reqData []byte, respData []byte) {
				for _, f := range filterRequestFuncs {
					reqData = f(reqData)
				}
				log.InfoWithContext(c.Request().Context(), "body_access_log", "path", c.Request().URL, "req", string(reqData), "resp", string(respData))
			},
			Skipper: middleware.DefaultSkipper})
	}
)

Functions

func AccessLog

func AccessLog(skipper middleware.Skipper) echo.MiddlewareFunc

func HandlerFuncWrapper

func HandlerFuncWrapper(fn HandlerFunc) echo.HandlerFunc

func PrometheusMetrics

func PrometheusMetrics(service string) func(echo.HandlerFunc) echo.HandlerFunc

PrometheusMetrics returns a prometheus metrics middlewaretools

func WrapContextWithUser

func WrapContextWithUser() func(echo.HandlerFunc) echo.HandlerFunc

Types

type APICode

type APICode int
const (
	APICodeOK  APICode = 0
	APICodeErr APICode = 500
)

type HandlerFunc

type HandlerFunc func(c echo.Context) (data interface{}, err error)

Jump to

Keyboard shortcuts

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