middleware

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package middleware provides HTTP middleware components for the backend server. It includes middleware for authentication, CORS, request logging, request ID tracking, and panic recovery to ensure robust and secure API operation.

Index

Constants

View Source
const RequestIDKey contextKey = "request_id"

Variables

This section is empty.

Functions

func Auth

func Auth(config AuthConfig) func(http.Handler) http.Handler

func CORS

func CORS(config CORSConfig) func(http.Handler) http.Handler

func GetRequestID

func GetRequestID(ctx context.Context) string

func Logging

func Logging(next http.Handler) http.Handler

func Recovery

func Recovery(next http.Handler) http.Handler

func RequestID

func RequestID(next http.Handler) http.Handler

Types

type AuthConfig

type AuthConfig struct {
	Enabled     bool
	APIPassword string
	APIKeyEnv   string
	PublicPaths []string
}

type CORSConfig

type CORSConfig struct {
	AllowedOrigins   []string
	AllowedMethods   []string
	AllowedHeaders   []string
	AllowCredentials bool
}

Jump to

Keyboard shortcuts

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