middleware

package
v0.0.0-...-a504e3d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultLogger

func GetDefaultLogger(serviceName, environment string) *logrus.Entry

GetDefaultLogger gets a default logger to use

func GetLoggerFromContext

func GetLoggerFromContext(ctx context.Context) *logrus.Entry

GetLoggerFromContext returns a logrus entry from the context, defaulting to a standard one if its not found

func HandlerFunc

func HandlerFunc(h func(w http.ResponseWriter, r *http.Request) error) http.Handler

HandlerFunc converts a handler with an error to a standard handler

func NoCache

func NoCache(h http.Handler) http.Handler

NoCache will add the following headers to the response:

Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0

func Recovery

func Recovery(h http.Handler) http.Handler

Recovery handles panics

func RequestID

func RequestID(h http.Handler) http.Handler

RequestID adds a request id to the context, if available it will use the one in the x-request-id header

func UserIDInjector

func UserIDInjector(h http.Handler) http.Handler

UserIDInjector add the user id to the context this is not validated for perf reasons

Types

type Logger

type Logger interface {
	Log(h http.Handler) http.Handler
}

Logger injects a logger into the context

func NewLogrusLogger

func NewLogrusLogger(baseEntry *logrus.Entry, logRequests bool) Logger

NewLogrusLogger allows you to setup a base entry to use for logging

type Timer

type Timer interface {
	Time(name string) alice.Constructor
}

Timer can time a handler and log it

func NewNullTimer

func NewNullTimer() Timer

Jump to

Keyboard shortcuts

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