middleware

package
v0.0.0-...-76bc61f Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

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

func RequestLogger(logger zerolog.Logger) fiber.Handler

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 JWTObj

type JWTObj struct {
	Secret []byte
}

func (*JWTObj) ValidateJWT

func (j *JWTObj) ValidateJWT(tokenStr string) (string, error)

type JWTValidator

type JWTValidator interface {
	ValidateJWT(token string) (string, error)
}

JWTValidator is an interface that defines a method for validating JWT tokens.

Jump to

Keyboard shortcuts

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