middleware

package
v0.0.0-...-96e757f Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogEntryCtxKey = &contextKey{"LogEntry"}

LogEntryCtxKey is the context.Context key to store the request log entry.

Functions

func GetEmail

func GetEmail(ctx context.Context) string

func GetGroups

func GetGroups(ctx context.Context) ([]string, error)

func PskValidatorMiddleware

func PskValidatorMiddleware(keys []string) func(next http.Handler) http.Handler

func RequestLogFields

func RequestLogFields(r *http.Request) log.Fields

RequestLogFields returns the in-context LogEntry for a request.

func RequestLogger

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

RequestLogger returns a logger handler using a custom LogFormatter.

func WithEmail

func WithEmail(ctx context.Context, email string) context.Context

func WithGroups

func WithGroups(ctx context.Context, groups []string) context.Context

Types

type Middleware

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

Middleware is a handler that exposes prometheus metrics for the number of requests, the latency and the response size, partitioned by status code, method and HTTP path.

func PrometheusMiddleware

func PrometheusMiddleware(name string, buckets ...float64) *Middleware

NewMiddleware returns a new prometheus Middleware handler.

func (*Middleware) Handler

func (m *Middleware) Handler() middleware

func (*Middleware) Initialize

func (m *Middleware) Initialize(path, method string, code int)

Jump to

Keyboard shortcuts

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