middleware

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

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

type Middleware func(http.Handler) http.Handler

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

Jump to

Keyboard shortcuts

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