middleware

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

Middleware is a function that takes an http.HandlerFunc and returns a new http.HandlerFunc which may execute code before and/or after calling the original handler.

func Logger

func Logger(logger *slog.Logger) Middleware

Logger creates a middleware that logs information about HTTP requests. It logs the request method, path, status code, and response time.

func MetricCollector

func MetricCollector() Middleware

MetricCollector creates a middleware that collects metrics about HTTP requests. This is a placeholder implementation that should be extended to integrate with your metrics collection system.

func PanicRecovery

func PanicRecovery(logger *slog.Logger) Middleware

PanicRecovery creates a middleware that recovers from panics in HTTP handlers. It logs the error and returns a 500 Internal Server Error response.

func StateDebugger

func StateDebugger(stateProvider func() string) Middleware

StateDebugger creates a middleware that adds the current server state to the response headers.

func WildcardRouter

func WildcardRouter(prefix string) Middleware

WildcardRouter creates a middleware that handles requests with a prefix pattern, stripping the prefix before passing to the handler, useful for passing a group of routes to a single handler function.

Jump to

Keyboard shortcuts

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