middleware

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCircuitBreakerOpen = errors.New("circuit breaker is open")

Functions

func CircuitBreakerModule

func CircuitBreakerModule(priority int) fx.Option

CircuitBreakerModule adds circuit breaker middleware to the application.

func ErrorLoggerModule

func ErrorLoggerModule(priority int) fx.Option

ErrorLoggerModule provides error logger middleware.

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 NewGinModule

func NewGinModule() fx.Option

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

10 - Recovery         - catches panics (must be first)
20 - Logger           - logs all requests
30 - ErrorLogger      - logs errors from ALL middleware and handlers
40 - Problem          - converts errors to RFC 7807 (must wrap all error sources)
50 - Timeout          - kills hanging requests
60 - CircuitBreaker   - protects against cascading failures
70 - RateLimit        - limits requests/second
80 - HTTPBulkhead     - limits concurrent requests

Note: OpenAPI validation is NOT included here - use ogen-generated servers which provide built-in validation with better type safety.

func ProblemModule

func ProblemModule(priority int) fx.Option

ProblemModule provides problem details middleware.

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  gin.HandlerFunc
}

Middleware represents a Gin middleware with priority.

Jump to

Keyboard shortcuts

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