Documentation
¶
Overview ¶
Package middleware provides reusable middleware components for the application. These include authentication, logging, and other request/response processing utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestLogger ¶
RequestLogger logs details about incoming HTTP requests and their responses. It logs the method, path, status, latency, and user ID (if available).
Parameters:
- logger: A zerolog.Logger instance for logging.
Returns:
- fiber.Handler: The middleware handler function.
func RequireAuth ¶
func RequireAuth(jwt JWTValidator) fiber.Handler
RequireAuth is a middleware that enforces authentication for protected routes. It validates the JWT token from the request and sets the user ID in the context.
Parameters:
- jwt: An implementation of the JWTValidator interface for token validation.
Returns:
- fiber.Handler: The middleware handler function.
Types ¶
type JWTValidator ¶
JWTValidator is an interface that defines a method for validating JWT tokens.
Click to show internal directories.
Click to hide internal directories.