middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicHealthHandler

func BasicHealthHandler(serviceName, version string) gin.HandlerFunc

BasicHealthHandler handler básico de health check

func DetailedHealthHandler

func DetailedHealthHandler(stack *MiddlewareStack) gin.HandlerFunc

DetailedHealthHandler handler detallado de health check

func LivenessHandler

func LivenessHandler(stack *MiddlewareStack) gin.HandlerFunc

LivenessHandler verifica si el servicio está vivo (no colgado)

func ReadinessHandler

func ReadinessHandler(stack *MiddlewareStack) gin.HandlerFunc

ReadinessHandler verifica si el servicio está listo para recibir tráfico

func RequestValidationMiddleware

func RequestValidationMiddleware(logger *logrus.Logger) gin.HandlerFunc

RequestValidationMiddleware valida requests básicas de seguridad

func SecurityHeadersMiddleware

func SecurityHeadersMiddleware() gin.HandlerFunc

SecurityHeadersMiddleware añade headers de seguridad estándar

func SecurityMetricsMiddleware

func SecurityMetricsMiddleware(collector metrics.MetricsCollector) gin.HandlerFunc

SecurityMetricsMiddleware registra métricas de seguridad

func TenantContextMiddleware

func TenantContextMiddleware(logger *logrus.Logger, requireTenant bool) gin.HandlerFunc

TenantContextMiddleware extrae y valida el contexto de tenant

Types

type HealthStatus

type HealthStatus struct {
	Status      string                 `json:"status"`
	Version     string                 `json:"version"`
	Service     string                 `json:"service"`
	Timestamp   string                 `json:"timestamp"`
	Uptime      string                 `json:"uptime,omitempty"`
	Environment string                 `json:"environment,omitempty"`
	Details     map[string]interface{} `json:"details,omitempty"`
}

HealthStatus representa el estado de salud

type MiddlewareStack

type MiddlewareStack struct {
	// Core components
	Logger      *logrus.Logger
	RedisClient *redis.Client

	// Configurations
	CORSConfig           *cors.Config
	LoggingConfig        *logging.LoggingConfig
	MetricsConfig        *metrics.MetricsConfig
	RateLimitConfig      *ratelimit.RateLimitConfig
	CircuitBreakerConfig *circuitbreaker.CircuitBreakerConfig
	RecoveryConfig       *recovery.RecoveryConfig

	// Components
	MetricsCollector       metrics.MetricsCollector
	CircuitBreakerMgr      *circuitbreaker.CircuitBreakerManager
	RecoveryStatsCollector *recovery.RecoveryStatsCollector

	// Settings
	EnableCORS           bool
	EnableLogging        bool
	EnableMetrics        bool
	EnableRateLimit      bool
	EnableCircuitBreaker bool
	EnableRecovery       bool
	EnableTenantContext  bool

	// Environment
	Environment    string // "development", "staging", "production"
	ServiceName    string
	ServiceVersion string
}

MiddlewareStack configuración completa del stack de middlewares

func DefaultMiddlewareStack

func DefaultMiddlewareStack(logger *logrus.Logger, serviceName string) *MiddlewareStack

DefaultMiddlewareStack retorna configuración por defecto

func DevelopmentMiddlewareStack

func DevelopmentMiddlewareStack(logger *logrus.Logger, serviceName string) *MiddlewareStack

DevelopmentMiddlewareStack configuración para desarrollo

func ProductionMiddlewareStack

func ProductionMiddlewareStack(logger *logrus.Logger, serviceName string) *MiddlewareStack

ProductionMiddlewareStack configuración para producción

func (*MiddlewareStack) ApplyHealthCheckRoutes

func (ms *MiddlewareStack) ApplyHealthCheckRoutes(router *gin.Engine)

ApplyHealthCheckRoutes añade rutas de health check

func (*MiddlewareStack) ApplyMiddlewares

func (ms *MiddlewareStack) ApplyMiddlewares(router *gin.Engine)

ApplyMiddlewares aplica todos los middlewares al router

func (*MiddlewareStack) ApplySecurityMiddlewares

func (ms *MiddlewareStack) ApplySecurityMiddlewares(router *gin.Engine)

ApplySecurityMiddlewares aplica middlewares de seguridad adicionales

func (*MiddlewareStack) DisableAll

func (ms *MiddlewareStack) DisableAll() *MiddlewareStack

DisableAll deshabilita todos los middlewares

func (*MiddlewareStack) EnableAll

func (ms *MiddlewareStack) EnableAll() *MiddlewareStack

EnableAll habilita todos los middlewares

func (*MiddlewareStack) GetStats

func (ms *MiddlewareStack) GetStats() map[string]interface{}

GetStats retorna estadísticas del stack completo

func (*MiddlewareStack) Initialize

func (ms *MiddlewareStack) Initialize() error

Initialize inicializa todos los componentes del stack

func (*MiddlewareStack) Shutdown

func (ms *MiddlewareStack) Shutdown() error

Shutdown limpia recursos del stack

func (*MiddlewareStack) WithEnvironment

func (ms *MiddlewareStack) WithEnvironment(env string) *MiddlewareStack

WithEnvironment configura el entorno

func (*MiddlewareStack) WithRedis

func (ms *MiddlewareStack) WithRedis(client *redis.Client) *MiddlewareStack

WithRedis configura Redis para el stack

func (*MiddlewareStack) WithServiceInfo

func (ms *MiddlewareStack) WithServiceInfo(name, version string) *MiddlewareStack

WithServiceInfo configura información del servicio

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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