middleware

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBulkheadFull = errors.New("too many concurrent requests")

ErrBulkheadFull is returned when bulkhead is full.

View Source
var ErrPanic = errors.New("internal server error")

ErrPanic is returned when a panic is recovered.

View Source
var ErrRateLimitExceeded = errors.New("rate limit exceeded")

ErrRateLimitExceeded is returned when rate limit is exceeded.

View Source
var ErrRequestTimeout = errors.New("request timeout")

ErrRequestTimeout is returned when request times out.

Functions

func HTTPBulkheadModule

func HTTPBulkheadModule(priority int) fx.Option

HTTPBulkheadModule adds HTTP bulkhead middleware to the application.

func LoggerModule

func LoggerModule(priority int) fx.Option

LoggerModule provides logger middleware.

func NewOgenMiddlewareModule added in v0.2.5

func NewOgenMiddlewareModule() fx.Option

NewOgenMiddlewareModule provides all ogen middleware modules. Middleware execution order (by priority, lower = earlier):

10 - Recovery         - catches panics (must be first)
20 - Logger           - logs all requests
30 - Timeout          - kills hanging requests
40 - RateLimit        - limits requests/second
50 - HTTPBulkhead     - limits concurrent requests

Note: ErrorLogger and Problem middlewares are not needed with ogen - use OgenErrorHandler which handles both logging and RFC 7807 responses.

func RateLimitModule

func RateLimitModule(priority int) fx.Option

RateLimitModule adds rate limiting middleware to the application.

func RecoveryModule

func RecoveryModule(priority int) fx.Option

RecoveryModule provides recovery middleware.

func TimeoutModule

func TimeoutModule(priority int) fx.Option

TimeoutModule adds timeout middleware to the application.

Types

type Middleware

type Middleware struct {
	Priority int
	Handler  middleware.Middleware
}

Middleware represents an ogen middleware with priority.

Jump to

Keyboard shortcuts

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