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.