Documentation
¶
Index ¶
- func CustomRateLimitResponse() gin.HandlerFunc
- func EndpointAuthMiddleware(endpointService EndpointService, authService EndpointAuthService, ...) gin.HandlerFunc
- func EndpointCORSMiddleware() gin.HandlerFunc
- func EndpointLookupMiddleware(endpointService EndpointService) gin.HandlerFunc
- func EndpointRateLimitMiddleware() gin.HandlerFunc
- func GetRewriteInfo(c *gin.Context) (bool, string, string)
- func GetServerID(c *gin.Context) string
- func GetSessionID(c *gin.Context) string
- func GetTransportContext(c *gin.Context) *types.TransportContext
- func GetTransportType(c *gin.Context) types.TransportType
- func IPRateLimit(config *IPRateLimitConfig) gin.HandlerFunc
- func IPRateLimitFromAppConfig(cfg *config.RateLimitConfig, redisCfg *config.RedisConfig) gin.HandlerFunc
- func IPRateLimitWithMemory(requestsPerMin int) gin.HandlerFunc
- func IPRateLimitWithRedis(requestsPerMin int, redisAddr, redisPassword string, redisDB int) gin.HandlerFunc
- func Recovery() gin.HandlerFunc
- func RecoveryWithConfig(config *RecoveryConfig) gin.HandlerFunc
- func RecoveryWithWriter(writer io.Writer) gin.HandlerFunc
- func SecureHeaders() gin.HandlerFunc
- func SecureHeadersWithConfig(config *SecurityConfig) gin.HandlerFunc
- func SecurityHeaders() gin.HandlerFunc
- func SecurityHeadersWithConfig(config *SecurityConfig) gin.HandlerFunc
- func ServerContextMiddleware() gin.HandlerFunc
- func SessionIDMiddleware() gin.HandlerFunc
- func Timeout() gin.HandlerFunc
- func TimeoutWithConfig(config *TimeoutConfig) gin.HandlerFunc
- func TransportTypeMiddleware() gin.HandlerFunc
- type Chain
- func AdminChain() *Chain
- func AuthenticatedChain() *Chain
- func DefaultChain() *Chain
- func DefaultChainFromConfig(cfg *config.Config) *Chain
- func DefaultChainWithAppConfig(cfg *config.Config, securityConfig *SecurityConfig) *Chain
- func DefaultChainWithConfig(securityConfig *SecurityConfig) *Chain
- func DefaultChainWithRateLimit(requestsPerMin int, redisAddr, redisPassword string, redisDB int) *Chain
- func NewChain() *Chain
- type EndpointAuthService
- type EndpointService
- type IPRateLimitConfig
- type OAuthService
- type PathRewriteConfig
- type PathRewriteMiddleware
- type RecoveryConfig
- type SecurityConfig
- type TimeoutConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomRateLimitResponse ¶
func CustomRateLimitResponse() gin.HandlerFunc
CustomRateLimitResponse provides a custom response for rate limit exceeded
func EndpointAuthMiddleware ¶
func EndpointAuthMiddleware(endpointService EndpointService, authService EndpointAuthService, oauthService OAuthService) gin.HandlerFunc
EndpointAuthMiddleware validates access to endpoint based on its auth settings
func EndpointCORSMiddleware ¶
func EndpointCORSMiddleware() gin.HandlerFunc
EndpointCORSMiddleware applies CORS settings based on endpoint configuration
func EndpointLookupMiddleware ¶
func EndpointLookupMiddleware(endpointService EndpointService) gin.HandlerFunc
EndpointLookupMiddleware resolves endpoint by name from URL
func EndpointRateLimitMiddleware ¶
func EndpointRateLimitMiddleware() gin.HandlerFunc
EndpointRateLimitMiddleware applies rate limiting based on endpoint configuration
func GetRewriteInfo ¶
GetRewriteInfo extracts rewrite information from Gin context
func GetServerID ¶
GetServerID extracts server ID from Gin context
func GetSessionID ¶
GetSessionID extracts session ID from Gin context
func GetTransportContext ¶
func GetTransportContext(c *gin.Context) *types.TransportContext
GetTransportContext extracts transport context from Gin context
func GetTransportType ¶
func GetTransportType(c *gin.Context) types.TransportType
GetTransportType extracts transport type from Gin context
func IPRateLimit ¶
func IPRateLimit(config *IPRateLimitConfig) gin.HandlerFunc
IPRateLimit creates IP-based rate limiting middleware
func IPRateLimitFromAppConfig ¶
func IPRateLimitFromAppConfig(cfg *config.RateLimitConfig, redisCfg *config.RedisConfig) gin.HandlerFunc
IPRateLimitFromAppConfig creates IP-based rate limiting middleware from app config
func IPRateLimitWithMemory ¶
func IPRateLimitWithMemory(requestsPerMin int) gin.HandlerFunc
IPRateLimitWithMemory creates IP rate limiting middleware with memory backend
func IPRateLimitWithRedis ¶
func IPRateLimitWithRedis(requestsPerMin int, redisAddr, redisPassword string, redisDB int) gin.HandlerFunc
IPRateLimitWithRedis creates IP rate limiting middleware with Redis backend
func Recovery ¶
func Recovery() gin.HandlerFunc
Recovery returns a middleware that recovers from panics
func RecoveryWithConfig ¶
func RecoveryWithConfig(config *RecoveryConfig) gin.HandlerFunc
RecoveryWithConfig returns a middleware that recovers from panics with custom configuration
func RecoveryWithWriter ¶
func RecoveryWithWriter(writer io.Writer) gin.HandlerFunc
RecoveryWithWriter returns a middleware that recovers from panics and writes to writer
func SecureHeaders ¶
func SecureHeaders() gin.HandlerFunc
SecureHeaders is an alias for SecurityHeaders for backward compatibility
func SecureHeadersWithConfig ¶
func SecureHeadersWithConfig(config *SecurityConfig) gin.HandlerFunc
SecureHeadersWithConfig is an alias for SecurityHeadersWithConfig for backward compatibility
func SecurityHeaders ¶
func SecurityHeaders() gin.HandlerFunc
SecurityHeaders returns a security headers middleware with default configuration
func SecurityHeadersWithConfig ¶
func SecurityHeadersWithConfig(config *SecurityConfig) gin.HandlerFunc
SecurityHeadersWithConfig returns a security headers middleware with custom configuration
func ServerContextMiddleware ¶
func ServerContextMiddleware() gin.HandlerFunc
ServerContextMiddleware extracts server context from rewritten paths
func SessionIDMiddleware ¶
func SessionIDMiddleware() gin.HandlerFunc
SessionIDMiddleware extracts or generates session IDs for stateful transports
func TimeoutWithConfig ¶
func TimeoutWithConfig(config *TimeoutConfig) gin.HandlerFunc
TimeoutWithConfig returns a middleware that times out requests with custom configuration
func TransportTypeMiddleware ¶
func TransportTypeMiddleware() gin.HandlerFunc
TransportTypeMiddleware determines the transport type from the request
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents a middleware chain
func AuthenticatedChain ¶
func AuthenticatedChain() *Chain
AuthenticatedChain creates a middleware chain for authenticated routes
func DefaultChain ¶
func DefaultChain() *Chain
DefaultChain creates a default middleware chain for the gateway
func DefaultChainFromConfig ¶
DefaultChainFromConfig creates a default middleware chain from app config
func DefaultChainWithAppConfig ¶
func DefaultChainWithAppConfig(cfg *config.Config, securityConfig *SecurityConfig) *Chain
DefaultChainWithAppConfig creates a default middleware chain with app and security config
func DefaultChainWithConfig ¶
func DefaultChainWithConfig(securityConfig *SecurityConfig) *Chain
DefaultChainWithConfig creates a default middleware chain with custom security config
func DefaultChainWithRateLimit ¶
func DefaultChainWithRateLimit(requestsPerMin int, redisAddr, redisPassword string, redisDB int) *Chain
DefaultChainWithRateLimit creates a default middleware chain with Redis rate limiting
func (*Chain) Apply ¶
func (c *Chain) Apply(group *gin.RouterGroup)
Apply applies the middleware chain to a gin router group
func (*Chain) Build ¶
func (c *Chain) Build() []gin.HandlerFunc
Build returns the middleware chain as a slice
type EndpointAuthService ¶
type EndpointAuthService interface { ValidateAPIKey(apiKey string) (*types.APIKey, error) GetUserByID(userID string) (*types.User, error) }
EndpointAuthService interface for validating API keys and OAuth tokens
type EndpointService ¶
type EndpointService interface {
ResolveEndpoint(ctx context.Context, name string) (*types.EndpointConfig, error)
}
EndpointService interface for endpoint operations
type IPRateLimitConfig ¶
type IPRateLimitConfig struct { RedisAddr string `yaml:"redis_addr"` RedisPassword string `yaml:"redis_password"` TrustedProxies []string `yaml:"trusted_proxies"` SkipPaths []string `yaml:"skip_paths"` CustomHeaders []string `yaml:"custom_headers"` RequestsPerMin int `yaml:"requests_per_minute"` BurstSize int `yaml:"burst_size"` RedisDB int `yaml:"redis_db"` Enabled bool `yaml:"enabled"` RedisEnabled bool `yaml:"redis_enabled"` }
IPRateLimitConfig holds the configuration for IP rate limiting
func DefaultIPRateLimitConfig ¶
func DefaultIPRateLimitConfig() *IPRateLimitConfig
DefaultIPRateLimitConfig returns default configuration
type OAuthService ¶
type OAuthService interface {
ValidateToken(ctx context.Context, bearerToken string) (*types.OAuthToken, error)
}
OAuthService interface for OAuth token validation
type PathRewriteConfig ¶
type PathRewriteConfig struct { LogLevel string `yaml:"log_level" json:"log_level"` Rules []types.PathRewriteRule `yaml:"rules" json:"rules"` Enabled bool `yaml:"enabled" json:"enabled"` }
PathRewriteConfig represents configuration for path rewriting
func (*PathRewriteConfig) ValidateConfig ¶
func (c *PathRewriteConfig) ValidateConfig() error
ValidateConfig validates the path rewrite configuration
type PathRewriteMiddleware ¶
type PathRewriteMiddleware struct {
// contains filtered or unexported fields
}
PathRewriteMiddleware handles path rewriting for server-specific endpoints
func NewPathRewriteMiddleware ¶
func NewPathRewriteMiddleware() *PathRewriteMiddleware
NewPathRewriteMiddleware creates a new path rewrite middleware
func (*PathRewriteMiddleware) AddRule ¶
func (p *PathRewriteMiddleware) AddRule(rule types.PathRewriteRule)
AddRule adds a custom rewrite rule
func (*PathRewriteMiddleware) GetRules ¶
func (p *PathRewriteMiddleware) GetRules() []types.PathRewriteRule
GetRules returns all rewrite rules
func (*PathRewriteMiddleware) Handler ¶
func (p *PathRewriteMiddleware) Handler() gin.HandlerFunc
Handler returns the Gin middleware handler
type RecoveryConfig ¶
type RecoveryConfig struct { // LogHandler handles panic logging LogHandler func(c *gin.Context, err interface{}, stack []byte) // RecoveryHandler handles the recovery process RecoveryHandler func(c *gin.Context, err interface{}) }
RecoveryConfig holds recovery middleware configuration
type SecurityConfig ¶
type SecurityConfig struct { CustomHeaders map[string]string ContentSecurityPolicy string XFrameOptions string XContentTypeOptions string ReferrerPolicy string PermissionsPolicy string StrictTransportSecurity string XXSSProtection string CrossOriginEmbedderPolicy string CrossOriginOpenerPolicy string CrossOriginResourcePolicy string }
SecurityConfig holds security headers configuration
func DefaultSecurityConfig ¶
func DefaultSecurityConfig() *SecurityConfig
DefaultSecurityConfig returns default security headers configuration
func DevelopmentSecurityConfig ¶
func DevelopmentSecurityConfig() *SecurityConfig
DevelopmentSecurityConfig returns security headers configuration suitable for development