middleware

package
v0.0.0-...-a1d1f9a Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware func(next fasthttp.RequestHandler) fasthttp.RequestHandler

Middleware wraps a fasthttp handler with additional behaviour.

func CORS

func CORS() Middleware

CORS adds Cross-Origin Resource Sharing headers and handles preflight.

func Chain

func Chain(mws ...Middleware) Middleware

Chain composes middlewares left-to-right: the first argument wraps outermost.

Chain(Recovery(), Logging(), SecureHeaders())(h)
// request path: Recovery → Logging → SecureHeaders → h

func Logging

func Logging() Middleware

Logging records method, path, remote addr, status code and latency for every request.

func RateLimit

func RateLimit(lim *limiter.Limiter) Middleware

RateLimit rejects requests with 429 when the per-second budget is exhausted.

func Recovery

func Recovery() Middleware

Recovery catches panics, logs them with a stack trace, and returns 500.

func RequestID

func RequestID() Middleware

RequestID sets X-Request-ID on the response if the client did not send one.

func SecureHeaders

func SecureHeaders() Middleware

SecureHeaders adds common security response headers.

Jump to

Keyboard shortcuts

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