middleware

package
v0.0.0-...-1c5cf23 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLogger *zap.Logger = zap.L()
)

Functions

func DefaultLogging

func DefaultLogging(log *zap.Logger) func(http.Handler) http.Handler

func DefaultRequestId

func DefaultRequestId() func(next http.Handler) http.Handler

DefaultRequestId creates default RequestId middleware.

func DefaultSentry

func DefaultSentry() func(http.Handler) http.Handler

func DefautSentryPanicHandler

func DefautSentryPanicHandler() func(*http.Request, interface{})

func GetLogger

func GetLogger(ctx context.Context) *zap.Logger

func GetRequestId

func GetRequestId(ctx context.Context) string

GetRequestId returns request identifier from supplied context, or an empty string when none is present.

func Logging

func Logging(log *zap.Logger, funcs ...FieldExtractor) func(http.Handler) http.Handler

func RequestId

func RequestId(header string, f RequestIdMaker) func(http.Handler) http.Handler

RequestId is a middleware that injects request identifier to the context and adds it to the response. When there is no header present containing request identifier, f is used to generate one.

func Sentry

func Sentry(header string, f func(*http.Request, interface{})) func(http.Handler) http.Handler

func Timeout

func Timeout(d time.Duration) func(http.Handler) http.Handler

func WithLogger

func WithLogger(ctx context.Context, log *zap.Logger) context.Context

Types

type FieldExtractor

type FieldExtractor func(r *http.Request) zap.Field

func WithHttpMethod

func WithHttpMethod(name string) FieldExtractor

func WithHttpPath

func WithHttpPath(name string) FieldExtractor

func WithHttpRemoteAddr

func WithHttpRemoteAddr(name string) FieldExtractor

func WithHttpRequestId

func WithHttpRequestId(name string) FieldExtractor

type RequestIdMaker

type RequestIdMaker func() string

Jump to

Keyboard shortcuts

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