Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chain ¶
func Chain(handler http.Handler, middlewares ...Middleware) http.Handler
Chain applies multiple middlewares to a handler in order Middlewares are applied from first to last, so the first middleware will be the outermost layer of the chain Example: Chain(handler, loggingMiddleware, authMiddleware) Results in: auth -> logging -> handler
func HandlerFunc ¶
func HandlerFunc(handler http.HandlerFunc, middlewares ...Middleware) http.HandlerFunc
HandlerFunc is a convenience function to wrap http.HandlerFunc with middleware
Types ¶
type Middleware ¶
Middleware defines the middleware function signature It takes a handler and returns a wrapped handler
func AuthorizationMiddleware ¶
func AuthorizationMiddleware(log *slog.Logger, jwtService *services.JWTService) Middleware
AuthorizationMiddleware creates a middleware that verifies JWT tokens from the Authorization header The token should be in the format: Authorization: Bearer <token>
func LoggingMiddleware ¶
func LoggingMiddleware(log *slog.Logger) Middleware
LoggingMiddleware creates a middleware that logs all HTTP requests Logs include: method, path, status code, response time, and request size