middleware

package
v1.8.25 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticationMiddleware added in v1.7.25

func AuthenticationMiddleware(adminToken string, idv *identity.Validator, enforcer *casbin.Enforcer) func(http.Handler) http.Handler

func Log

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

func LogFromRequest

func LogFromRequest(r *http.Request) *zap.Logger

func Logger

func Logger() func(next http.Handler) http.Handler

func Messaging added in v1.7.23

func Messaging(next http.Handler) http.Handler

func Metrics

func Metrics(next http.Handler) http.Handler

Metrics adapts the incoming request with Logging/Metrics

func Paging added in v1.8.1

func Paging(defaultLimit uint64) func(next http.Handler) http.Handler

func RequestID

func RequestID(next http.Handler) http.Handler

RequestID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.

func RequestLogger

func RequestLogger(f LogConstructor) func(next http.Handler) http.Handler

func SetupMiddleware

func SetupMiddleware(r chi.Router, timeout time.Duration)

func WithLogEntry

func WithLogEntry(r *http.Request, entry LogWriter) *http.Request

Types

type LogConstructor

type LogConstructor interface {
	NewLogWriter(r *http.Request) LogWriter
}

type LogEntry

type LogEntry struct {
	// contains filtered or unexported fields
}

func (*LogEntry) Panic

func (l *LogEntry) Panic(v interface{}, stack []byte)

func (*LogEntry) Write

func (l *LogEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, body io.ReadCloser)

type LogWriter

type LogWriter interface {
	Write(status, bytes int, header http.Header, elapsed time.Duration, body io.ReadCloser)
	Panic(v interface{}, stack []byte)
}

type LogWriterConstructor

type LogWriterConstructor struct {
	// contains filtered or unexported fields
}

func (*LogWriterConstructor) NewLogWriter

func (l *LogWriterConstructor) NewLogWriter(r *http.Request) LogWriter

type MetricsProvider

type MetricsProvider interface {
}

Jump to

Keyboard shortcuts

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