middleware

package
v0.0.0-...-7add6ca Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logging

func Logging(next http.Handler) http.Handler

Logging logs every HTTP request with method, path, status, and duration.

func RateLimit

func RateLimit(limiter *IPRateLimiter) func(http.Handler) http.Handler

RateLimit returns middleware that limits requests per IP.

func Recovery

func Recovery(next http.Handler) http.Handler

Recovery catches panics in HTTP handlers and returns 500.

func Timeout

func Timeout(d time.Duration, next http.Handler) http.Handler

Timeout wraps a handler with a context deadline. If the handler exceeds the given duration, the context is cancelled.

Types

type IPRateLimiter

type IPRateLimiter struct {
	// contains filtered or unexported fields
}

IPRateLimiter provides per-IP rate limiting.

func NewIPRateLimiter

func NewIPRateLimiter(rate float64, burst int) *IPRateLimiter

NewIPRateLimiter creates a rate limiter. rate is requests per second, burst is the max burst size.

Jump to

Keyboard shortcuts

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