middleware

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyLimit

func BodyLimit(limit int64) goexpress.Middleware

BodyLimit limits the size of request bodies

func CORS

func CORS(config ...CORSConfig) goexpress.Middleware

CORS returns a CORS middleware

func Logger

func Logger() goexpress.Middleware

Logger logs HTTP requests

func RateLimit

func RateLimit(config RateLimitConfig) goexpress.Middleware

RateLimit returns a rate limiting middleware (simple in-memory implementation)

func Recovery

func Recovery() goexpress.Middleware

Recovery recovers from panics and returns a 500 error

func Secure

func Secure() goexpress.Middleware

Secure adds security headers

Types

type CORSConfig

type CORSConfig struct {
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	ExposeHeaders    []string
	AllowCredentials bool
	MaxAge           int
}

CORSConfig holds CORS configuration

func DefaultCORSConfig

func DefaultCORSConfig() CORSConfig

DefaultCORSConfig returns a default CORS configuration

type RateLimitConfig

type RateLimitConfig struct {
	Max     int           // Maximum requests
	Window  time.Duration // Time window
	KeyFunc func(*goexpress.Context) string
	Handler goexpress.HandlerFunc
}

RateLimitConfig holds rate limiting configuration

Jump to

Keyboard shortcuts

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