middleware

package
v0.0.0-...-5c49fd7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recovery

func Recovery(next http.Handler) http.Handler

Recovery is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possible. Recoverer prints a request ID if one is provided.

Alternatively, look at https://github.com/pressly/lg middleware pkgs.

Types

type Logger

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

Logger is a middleware that injects logger with request ID into the context of each request.

func NewLogger

func NewLogger(logger *slog.Logger) *Logger

NewLogger creates new Logger instance

func (*Logger) Handler

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

Handler is the request handler that creates logger instance for each request with corresponding request ID.

type RequestLogger

type RequestLogger struct{}

RequestLogger is a middleware that logs request data

func NewRequestLogger

func NewRequestLogger() *RequestLogger

NewRequestLogger creates new RequestLogger instance

func (*RequestLogger) Handler

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

Handler is the request handler that logs request data

Jump to

Keyboard shortcuts

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