Back to godoc.org
github.com/oldfritter/echo-middleware/v4

Package middleware

v4.0.3
Latest Go to latest

The highest tagged major version is v4.

Published: Jun 29, 2020 | License: MIT | Module: github.com/oldfritter/echo-middleware/v4

Index

Constants

const (
	// NEWRELIC_TXN defines the context key used to save newrelic transaction
	NEWRELIC_TXN = "newrelic-txn"
)

Variables

var (
	// DefaultLogrusConfig is the default Logrus middleware config.
	DefaultLogrusConfig = LogrusConfig{
		FieldMap: map[string]string{
			"id":            "@id",
			"remote_ip":     "@remote_ip",
			"uri":           "@uri",
			"host":          "@host",
			"method":        "@method",
			"status":        "@status",
			"latency":       "@latency",
			"latency_human": "@latency_human",
			"bytes_in":      "@bytes_in",
			"bytes_out":     "@bytes_out",
		},
		Logger:  logrus.StandardLogger(),
		Skipper: mw.DefaultSkipper,
	}
)

func LoggerWithOutput

func LoggerWithOutput(w io.Writer) echo.MiddlewareFunc

LoggerWithOutput returns a Logger middleware with output. See: `Logger()`.

func Logrus

func Logrus() echo.MiddlewareFunc

Logrus returns a middleware that logs HTTP requests.

func LogrusWithConfig

func LogrusWithConfig(config LogrusConfig) echo.MiddlewareFunc

LogrusWithConfig returns a Logrus middleware with config. See: `Logrus()`.

func NewRelic

func NewRelic(appName string, licenseKey string) echo.MiddlewareFunc

NewRelic returns a middleware that collect request data for NewRelic

func NewRelicWithApplication

func NewRelicWithApplication(app nr.Application) echo.MiddlewareFunc

NewRelicWithApplication returns a NewRelic middleware with application. See: `NewRelic()`.

type LogrusConfig

type LogrusConfig struct {
	// FieldMap set a list of fields with tags
	//
	// Tags to constructed the logger fields.
	//
	// - @id (Request ID)
	// - @remote_ip
	// - @uri
	// - @host
	// - @method
	// - @path
	// - @referer
	// - @user_agent
	// - @status
	// - @latency (In nanoseconds)
	// - @latency_human (Human readable)
	// - @bytes_in (Bytes received)
	// - @bytes_out (Bytes sent)
	// - @header:<NAME>
	// - @query:<NAME>
	// - @form:<NAME>
	// - @cookie:<NAME>
	FieldMap map[string]string

	// Logger it is a logrus logger
	Logger logrus.FieldLogger

	// Skipper defines a function to skip middleware.
	Skipper mw.Skipper
}

LogrusConfig defines the config for Logrus middleware.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier