Documentation
¶
Index ¶
- Constants
- Variables
- func AddSpanAttributes(ctx context.Context, attrs ...attribute.KeyValue)
- func AddSpanEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)
- func AllowLocalhostOnly() gin.HandlerFunc
- func AllowPrivateNetworks() gin.HandlerFunc
- func AllowSpecificIPs(ips []string) gin.HandlerFunc
- func AllowSpecificNetworks(networks []string) gin.HandlerFunc
- func BroadcastHandler(conn *WebSocketConnection, message *WebSocketMessage) error
- func CacheByEndpoint(config *CacheConfig) gin.HandlerFunc
- func CacheByURL(config *CacheConfig) gin.HandlerFunc
- func CacheByUserURL(config *CacheConfig) gin.HandlerFunc
- func CacheMiddleware(config *CacheConfig, keyGen CacheKeyFunc) gin.HandlerFunc
- func CacheStatsHandler(store CacheStore) gin.HandlerFunc
- func ClearSchemas()
- func CreateAuthMiddleware(args string) func(c *gin.Context)
- func CreateCORSMiddleware(args string) func(c *gin.Context)
- func CreateCacheMiddleware(args string) func(c *gin.Context)
- func CreateMetricsMiddleware(args string) func(c *gin.Context)
- func CreateProxyMiddleware(args string) gin.HandlerFunc
- func CreateRateLimitMiddleware(args string) func(c *gin.Context)
- func CreateSecurityMiddleware(args string) gin.HandlerFunc
- func CreateWebSocketHandler(config *WebSocketConfig) gin.HandlerFunc
- func CreateWebSocketMiddleware(args string) gin.HandlerFunc
- func CreateWebSocketStatsMiddleware(args string) gin.HandlerFunc
- func CustomCache(ttl time.Duration, keyGen CacheKeyFunc, cacheType string) gin.HandlerFunc
- func CustomCheckOrigin(allowedOrigins []string) func(r *http.Request) bool
- func CustomRateLimit(limit int, window time.Duration, keyGen KeyGeneratorFunc, ...) gin.HandlerFunc
- func Default() *gin.Engine
- func DefaultWithSecurity(securityConfig *SecurityConfig) *gin.Engine
- func DocsHandler(c *gin.Context)
- func DocsJSONHandler(c *gin.Context)
- func EchoHandler(conn *WebSocketConnection, message *WebSocketMessage) error
- func GenerateClientSDKs(config *ClientSDKConfig) error
- func GenerateFromTemplate(rootDir, templatePath, outputPath, pkgName string) error
- func GenerateInitFile(rootDir, outputPath, pkgName string) error
- func GenerateInitFileWithConfig(rootDir, outputPath, pkgName string, config *Config) error
- func GetGroups() map[string]*GroupInfo
- func GetMarkers() map[string]MarkerConfig
- func GetMinifiedTemplate() string
- func GetSchemas() map[string]*SchemaInfo
- func GetValidatedData(c *gin.Context) (interface{}, bool)
- func GetValidatedQuery(c *gin.Context) (interface{}, bool)
- func GetWebSocketInfo(config WebSocketConfig) map[string]interface{}
- func HealthCheckHandler() gin.HandlerFunc
- func HealthCheckWithTracing() gin.HandlerFunc
- func InstrumentedHandler(handlerName string, handler gin.HandlerFunc) gin.HandlerFunc
- func InvalidateCacheHandler(store CacheStore) gin.HandlerFunc
- func JoinGroupHandler(conn *WebSocketConnection, message *WebSocketMessage) error
- func LeaveGroupHandler(conn *WebSocketConnection, message *WebSocketMessage) error
- func LogNormal(format string, args ...interface{})
- func LogSilent(format string, args ...interface{})
- func LogVerbose(format string, args ...interface{})
- func MetricsMiddleware(config *MetricsConfig) gin.HandlerFunc
- func MinifyCode(inputPath, outputPath string, enabled bool) error
- func OpenAPIJSONHandler(config *Config) gin.HandlerFunc
- func OpenAPIYAMLHandler(config *Config) gin.HandlerFunc
- func PrometheusHandler() gin.HandlerFunc
- func RateLimitByEndpoint(config *RateLimitConfig) gin.HandlerFunc
- func RateLimitByIP(config *RateLimitConfig) gin.HandlerFunc
- func RateLimitByUser(config *RateLimitConfig) gin.HandlerFunc
- func RateLimitMiddleware(config *RateLimitConfig, keyGen KeyGeneratorFunc) gin.HandlerFunc
- func RecordCacheHit(cacheType, keyType string)
- func RecordCacheMiss(cacheType, keyType string)
- func RecordCacheSize(cacheType string, size float64)
- func RecordMiddlewareError(middleware, errorType string)
- func RecordMiddlewareTime(middleware, endpoint string, duration time.Duration)
- func RecordRateLimitExceeded(endpoint, limitType string)
- func RecordRateLimitHit(endpoint, limitType string)
- func RecordValidationError(validationType, field string)
- func RecordValidationTime(validationType string, duration time.Duration)
- func RegisterDefaultHandlers()
- func RegisterDefaultWebSocketHandlers()
- func RegisterGeneratorHook(h GeneratorHook)
- func RegisterMarker(config MarkerConfig)
- func RegisterParserHook(h ParserHook)
- func RegisterRoute(method, path string, handlers ...gin.HandlerFunc)
- func RegisterRouteWithMeta(entry *RouteEntry)
- func RegisterSchema(schema *SchemaInfo)
- func RegisterWebSocketHandler(messageType string, handler WebSocketHandler)
- func SaveConfig(config *Config, configPath string) error
- func SecureInternalEndpoints(config *SecurityConfig) gin.HandlerFunc
- func SetLogLevel(level LogLevel)
- func SetSpanError(ctx context.Context, err error)
- func SetVerbose(verbose bool)
- func SpanFromContext(ctx context.Context) trace.Span
- func StartSpan(ctx context.Context, name string) (context.Context, trace.Span)
- func SwaggerRedirectHandler(c *gin.Context)
- func SwaggerUIHandler(_ *Config) gin.HandlerFunc
- func TraceCacheOperation(ctx context.Context, operation, cacheType, key string) (context.Context, trace.Span)
- func TraceMiddleware(middlewareName string) gin.HandlerFunc
- func TraceRateLimitOperation(ctx context.Context, operation, limitType string, allowed bool) (context.Context, trace.Span)
- func TraceValidationOperation(ctx context.Context, validationType string, fieldCount int) (context.Context, trace.Span)
- func TraceWebSocketOperation(ctx context.Context, operation, connectionID string) (context.Context, trace.Span)
- func TracingMiddleware(config *TelemetryConfig) gin.HandlerFunc
- func TracingStatsHandler() gin.HandlerFunc
- func ValidateGeneration(generatedPath string) error
- func ValidateJSON(target interface{}, config *ValidationConfig) gin.HandlerFunc
- func ValidateParams(rules map[string]string, config *ValidationConfig) gin.HandlerFunc
- func ValidateQuery(target interface{}, config *ValidationConfig) gin.HandlerFunc
- func ValidateStruct(config *ValidationConfig) gin.HandlerFunc
- func WebSocketHandlerWrapper(handler WebSocketHandler) gin.HandlerFunc
- func WebSocketStatsHandler() gin.HandlerFunc
- type CacheConfig
- type CacheEntry
- type CacheKeyFunc
- type CacheStats
- type CacheStore
- type CircuitBreaker
- type CircuitBreakerConfig
- type CircuitBreakerImpl
- type CircuitBreakerState
- type ClientSDKConfig
- type Config
- type ConsulConfig
- type ConsulDiscovery
- type Contact
- type DNSConfig
- type DNSDiscovery
- type Debouncer
- type DevConfig
- type Discriminator
- type DocsData
- type Encoding
- type EntityMeta
- type Example
- type ExternalDocs
- type FieldMeta
- type FileWatcher
- type FrameworkStats
- type GenData
- type GenerationConfig
- type GeneratorHook
- type GoSDKGenerator
- type GroupInfo
- type HTTPClientConfig
- type HandlersConfig
- type Header
- type HealthChecker
- type HealthCheckerImpl
- type IPHashLoadBalancer
- type JavaScriptSDKGenerator
- type K8sDiscovery
- type KeyGeneratorFunc
- type KubernetesConfig
- type LeastConnectionsLoadBalancer
- type License
- type Link
- type LoadBalancer
- type LoadBalancingConfig
- type LogLevel
- type Logger
- type MarkerConfig
- type MarkerFactory
- type MarkerInstance
- type MediaType
- type MemoryCache
- func (m *MemoryCache) Clear(ctx context.Context) error
- func (m *MemoryCache) Delete(ctx context.Context, key string) error
- func (m *MemoryCache) Get(ctx context.Context, key string) (*CacheEntry, error)
- func (m *MemoryCache) Set(ctx context.Context, key string, entry *CacheEntry, ttl time.Duration) error
- func (m *MemoryCache) Stats() CacheStats
- type MemoryRateLimiter
- type MetricsCollector
- type MetricsConfig
- type MetricsInfo
- type MiddlewareInfo
- type MultipleValidationError
- type OAuthFlow
- type OAuthFlows
- type OpenAPIComponents
- type OpenAPIConfig
- type OpenAPIInfo
- type OpenAPIOperation
- type OpenAPIParameter
- type OpenAPIPath
- type OpenAPIRequestBody
- type OpenAPIResponse
- type OpenAPISchema
- type OpenAPIServer
- type OpenAPISpec
- type OpenAPITag
- type ParameterInfo
- type ParserHook
- type ParserStats
- type ProdConfig
- type PropertyInfo
- type ProxyConfig
- type ProxyConfigSettings
- type ProxyInstance
- type ProxyManager
- type PythonSDKGenerator
- type RateLimitConfig
- type RateLimitResponse
- type RateLimiter
- type RedisCache
- func (r *RedisCache) Clear(ctx context.Context) error
- func (r *RedisCache) Delete(ctx context.Context, key string) error
- func (r *RedisCache) Get(ctx context.Context, key string) (*CacheEntry, error)
- func (r *RedisCache) Set(ctx context.Context, key string, entry *CacheEntry, ttl time.Duration) error
- func (r *RedisCache) Stats() CacheStats
- type RedisConfig
- type RedisRateLimiter
- type ResponseInfo
- type RetryConfig
- type RoundRobinLoadBalancer
- type Route
- type RouteEntry
- type RouteMeta
- type SDKGenerator
- type SDKManager
- type SchemaInfo
- type SecurityConfig
- type SecurityRequirement
- type SecurityScheme
- type ServerVariable
- type ServiceDiscovery
- type ServiceDiscoveryConfig
- type StaticDiscovery
- type TelemetryConfig
- type TelemetryManager
- type TokenBucket
- type TracingInfo
- type TypeScriptSDKGenerator
- type ValidationConfig
- type ValidationError
- type ValidationField
- type ValidationResponse
- type WebSocketConfig
- type WebSocketConnection
- type WebSocketHandler
- type WebSocketHub
- func (h *WebSocketHub) Broadcast(message *WebSocketMessage)
- func (h *WebSocketHub) JoinGroup(connID, groupName string) error
- func (h *WebSocketHub) LeaveGroup(connID, groupName string) error
- func (h *WebSocketHub) SendToConnection(connID string, message *WebSocketMessage)
- func (h *WebSocketHub) SendToGroup(groupName string, message *WebSocketMessage)
- type WebSocketMessage
- type WebSocketRouter
- type WeightedRoundRobinLoadBalancer
- type XML
Constants ¶
const ( DefaultTimeout = "10s" DefaultRetries = 3 DefaultRetryDelay = "1s" DefaultHealthInterval = "30s" DefaultFailureThreshold = 5 DefaultCircuitBreaker = "30s" )
Default configurations
Variables ¶
var ( URLCacheKey = func(c *gin.Context) string { return fmt.Sprintf("cache:url:%s:%s", c.Request.Method, c.Request.URL.Path) } UserURLCacheKey = func(c *gin.Context) string { userID := c.GetString("user_id") if userID == "" { userID = "anonymous" } return fmt.Sprintf("cache:user:%s:url:%s:%s", userID, c.Request.Method, c.Request.URL.Path) } EndpointCacheKey = func(c *gin.Context) string { path := c.FullPath() if path == "" { path = c.Request.URL.Path } return fmt.Sprintf("cache:endpoint:%s:%s", c.Request.Method, path) } )
Default cache key generation functions
var ( IPKeyGenerator = func(c *gin.Context) string { return "ratelimit:ip:" + c.ClientIP() } UserKeyGenerator = func(c *gin.Context) string { userID := c.GetString("user_id") if userID == "" { return "ratelimit:anonymous:" + c.ClientIP() } return "ratelimit:user:" + userID } EndpointKeyGenerator = func(c *gin.Context) string { return fmt.Sprintf("ratelimit:endpoint:%s:%s:%s", c.Request.Method, c.FullPath(), c.ClientIP()) } )
Default key generation functions
var WebSocketUpgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, CheckOrigin: func(_ *http.Request) bool { return true }, }
WebSocketUpgrader configuration for connection upgrade WebSocket
Functions ¶
func AddSpanAttributes ¶
AddSpanAttributes adds attributes to current span
func AddSpanEvent ¶
AddSpanEvent adds event to current span
func AllowLocalhostOnly ¶ added in v0.10.0
func AllowLocalhostOnly() gin.HandlerFunc
AllowLocalhostOnly creates a middleware that only allows localhost access
func AllowPrivateNetworks ¶ added in v0.10.0
func AllowPrivateNetworks() gin.HandlerFunc
AllowPrivateNetworks creates a middleware that allows private network access
func AllowSpecificIPs ¶ added in v0.10.0
func AllowSpecificIPs(ips []string) gin.HandlerFunc
AllowSpecificIPs creates a middleware that allows specific IP addresses
func AllowSpecificNetworks ¶ added in v0.10.0
func AllowSpecificNetworks(networks []string) gin.HandlerFunc
AllowSpecificNetworks creates a middleware that allows specific networks
func BroadcastHandler ¶
func BroadcastHandler(conn *WebSocketConnection, message *WebSocketMessage) error
BroadcastHandler handler for broadcast
func CacheByEndpoint ¶
func CacheByEndpoint(config *CacheConfig) gin.HandlerFunc
CacheByEndpoint cache middleware by endpoint
func CacheByURL ¶
func CacheByURL(config *CacheConfig) gin.HandlerFunc
CacheByURL cache middleware by URL
func CacheByUserURL ¶
func CacheByUserURL(config *CacheConfig) gin.HandlerFunc
CacheByUserURL cache middleware by user and URL
func CacheMiddleware ¶
func CacheMiddleware(config *CacheConfig, keyGen CacheKeyFunc) gin.HandlerFunc
CacheMiddleware creates cache middleware
func CacheStatsHandler ¶
func CacheStatsHandler(store CacheStore) gin.HandlerFunc
CacheStatsHandler handler for cache statistics
func ClearSchemas ¶
func ClearSchemas()
ClearSchemas clears all registered schemas (useful for testing)
func CreateAuthMiddleware ¶
CreateAuthMiddleware creates auth middleware (wrapper for generation)
func CreateCORSMiddleware ¶
CreateCORSMiddleware creates CORS middleware (wrapper for generation)
func CreateCacheMiddleware ¶
CreateCacheMiddleware creates cache middleware (wrapper for generation)
func CreateMetricsMiddleware ¶
CreateMetricsMiddleware creates metrics middleware (wrapper for generation)
func CreateProxyMiddleware ¶ added in v0.10.0
func CreateProxyMiddleware(args string) gin.HandlerFunc
CreateProxyMiddleware creates proxy middleware (wrapper for generation)
func CreateRateLimitMiddleware ¶
CreateRateLimitMiddleware creates rate limit middleware (wrapper for generation)
func CreateSecurityMiddleware ¶ added in v0.10.0
func CreateSecurityMiddleware(args string) gin.HandlerFunc
CreateSecurityMiddleware creates security middleware (wrapper for generation)
func CreateWebSocketHandler ¶
func CreateWebSocketHandler(config *WebSocketConfig) gin.HandlerFunc
CreateWebSocketHandler creates handler for WebSocket connections
func CreateWebSocketMiddleware ¶
func CreateWebSocketMiddleware(args string) gin.HandlerFunc
CreateWebSocketMiddleware creates WebSocket middleware (wrapper for generation)
func CreateWebSocketStatsMiddleware ¶
func CreateWebSocketStatsMiddleware(args string) gin.HandlerFunc
CreateWebSocketStatsMiddleware creates WebSocket stats middleware (wrapper for generation)
func CustomCache ¶
func CustomCache(ttl time.Duration, keyGen CacheKeyFunc, cacheType string) gin.HandlerFunc
CustomCache customizable cache middleware
func CustomCheckOrigin ¶ added in v0.10.0
CustomCheckOrigin allows customizable origin checking via parameter
func CustomRateLimit ¶
func CustomRateLimit(limit int, window time.Duration, keyGen KeyGeneratorFunc, rateLimiterType string) gin.HandlerFunc
CustomRateLimit customizable rate limiting middleware
func DefaultWithSecurity ¶ added in v0.10.0
func DefaultWithSecurity(securityConfig *SecurityConfig) *gin.Engine
DefaultWithSecurity creates a gin.Engine with security configuration for internal endpoints
func DocsJSONHandler ¶
DocsJSONHandler serves documentation in JSON/OpenAPI format
func EchoHandler ¶
func EchoHandler(conn *WebSocketConnection, message *WebSocketMessage) error
EchoHandler echo handler for testing
func GenerateClientSDKs ¶
func GenerateClientSDKs(config *ClientSDKConfig) error
GenerateClientSDKs generates client SDKs for multiple languages
func GenerateFromTemplate ¶
GenerateFromTemplate generates code using custom template
func GenerateInitFile ¶
GenerateInitFile generates the init_decorators.go file for production
func GenerateInitFileWithConfig ¶
GenerateInitFileWithConfig generates file with specific configuration
func GetMarkers ¶
func GetMarkers() map[string]MarkerConfig
GetMarkers returns all registered markers
func GetMinifiedTemplate ¶
func GetMinifiedTemplate() string
GetMinifiedTemplate returns minified template for generation
func GetSchemas ¶
func GetSchemas() map[string]*SchemaInfo
GetSchemas returns all registered schemas
func GetValidatedData ¶
GetValidatedData extracts validated data from context
func GetValidatedQuery ¶
GetValidatedQuery extracts validated query from context
func GetWebSocketInfo ¶
func GetWebSocketInfo(config WebSocketConfig) map[string]interface{}
GetWebSocketInfo returns information about WebSocket
func HealthCheckHandler ¶
func HealthCheckHandler() gin.HandlerFunc
HealthCheckHandler health check handler with metrics
func HealthCheckWithTracing ¶
func HealthCheckWithTracing() gin.HandlerFunc
HealthCheckWithTracing instrumented health check
func InstrumentedHandler ¶
func InstrumentedHandler(handlerName string, handler gin.HandlerFunc) gin.HandlerFunc
InstrumentedHandler wrapper to instrument custom handlers
func InvalidateCacheHandler ¶
func InvalidateCacheHandler(store CacheStore) gin.HandlerFunc
InvalidateCacheHandler handler to invalidate cache
func JoinGroupHandler ¶
func JoinGroupHandler(conn *WebSocketConnection, message *WebSocketMessage) error
JoinGroupHandler handler to join group
func LeaveGroupHandler ¶
func LeaveGroupHandler(conn *WebSocketConnection, message *WebSocketMessage) error
LeaveGroupHandler handler to leave group
func LogNormal ¶
func LogNormal(format string, args ...interface{})
LogNormal imprime log em modo normal e verbose
func LogSilent ¶
func LogSilent(format string, args ...interface{})
LogSilent always prints log (used for important errors)
func LogVerbose ¶
func LogVerbose(format string, args ...interface{})
LogVerbose imprime log apenas em modo verbose
func MetricsMiddleware ¶
func MetricsMiddleware(config *MetricsConfig) gin.HandlerFunc
MetricsMiddleware main middleware for metrics collection
func MinifyCode ¶
MinifyCode minifies Go code by removing comments and unnecessary spaces
func OpenAPIJSONHandler ¶
func OpenAPIJSONHandler(config *Config) gin.HandlerFunc
OpenAPIJSONHandler serves OpenAPI 3.0 documentation in JSON
func OpenAPIYAMLHandler ¶
func OpenAPIYAMLHandler(config *Config) gin.HandlerFunc
OpenAPIYAMLHandler serves OpenAPI 3.0 documentation in YAML
func PrometheusHandler ¶
func PrometheusHandler() gin.HandlerFunc
PrometheusHandler returns Prometheus handler
func RateLimitByEndpoint ¶
func RateLimitByEndpoint(config *RateLimitConfig) gin.HandlerFunc
RateLimitByEndpoint rate limiting middleware by endpoint
func RateLimitByIP ¶
func RateLimitByIP(config *RateLimitConfig) gin.HandlerFunc
RateLimitByIP rate limiting middleware by IP
func RateLimitByUser ¶
func RateLimitByUser(config *RateLimitConfig) gin.HandlerFunc
RateLimitByUser rate limiting middleware by user
func RateLimitMiddleware ¶
func RateLimitMiddleware(config *RateLimitConfig, keyGen KeyGeneratorFunc) gin.HandlerFunc
RateLimitMiddleware creates rate limiting middleware
func RecordCacheHit ¶
func RecordCacheHit(cacheType, keyType string)
RecordCacheHit registra hit de cache
func RecordCacheMiss ¶
func RecordCacheMiss(cacheType, keyType string)
RecordCacheMiss registra miss de cache
func RecordCacheSize ¶
RecordCacheSize registra tamanho do cache
func RecordMiddlewareError ¶
func RecordMiddlewareError(middleware, errorType string)
RecordMiddlewareError records middleware error
func RecordMiddlewareTime ¶
RecordMiddlewareTime records middleware execution time
func RecordRateLimitExceeded ¶
func RecordRateLimitExceeded(endpoint, limitType string)
RecordRateLimitExceeded registra rate limit excedido
func RecordRateLimitHit ¶
func RecordRateLimitHit(endpoint, limitType string)
RecordRateLimitHit records rate limit check
func RecordValidationError ¶
func RecordValidationError(validationType, field string)
RecordValidationError records validation error
func RecordValidationTime ¶
RecordValidationTime records validation time
func RegisterDefaultHandlers ¶
func RegisterDefaultHandlers()
RegisterDefaultHandlers registers default handlers
func RegisterDefaultWebSocketHandlers ¶
func RegisterDefaultWebSocketHandlers()
RegisterDefaultWebSocketHandlers is a public alias for RegisterDefaultHandlers
func RegisterGeneratorHook ¶
func RegisterGeneratorHook(h GeneratorHook)
RegisterGeneratorHook registers a generation hook
func RegisterMarker ¶
func RegisterMarker(config MarkerConfig)
RegisterMarker registers a new marker in the framework
func RegisterParserHook ¶
func RegisterParserHook(h ParserHook)
RegisterParserHook registers a parsing hook
func RegisterRoute ¶
func RegisterRoute(method, path string, handlers ...gin.HandlerFunc)
RegisterRoute registers a new route in the framework
func RegisterRouteWithMeta ¶
func RegisterRouteWithMeta(entry *RouteEntry)
RegisterRouteWithMeta registers a route with complete metadata
func RegisterSchema ¶
func RegisterSchema(schema *SchemaInfo)
RegisterSchema registers a new schema in the framework
func RegisterWebSocketHandler ¶
func RegisterWebSocketHandler(messageType string, handler WebSocketHandler)
RegisterWebSocketHandler allows applications to register custom WebSocket handlers
func SaveConfig ¶
SaveConfig saves configuration to file
func SecureInternalEndpoints ¶ added in v0.10.0
func SecureInternalEndpoints(config *SecurityConfig) gin.HandlerFunc
SecureInternalEndpoints creates a middleware to secure internal gin-decorators endpoints
func SetSpanError ¶
SetSpanError marca span como error
func SpanFromContext ¶
SpanFromContext extracts span from context
func SwaggerRedirectHandler ¶
SwaggerRedirectHandler redirects to swagger UI (convenience endpoint)
func SwaggerUIHandler ¶
func SwaggerUIHandler(_ *Config) gin.HandlerFunc
SwaggerUIHandler creates Swagger UI handler with customizable settings via config
func TraceCacheOperation ¶
func TraceCacheOperation(ctx context.Context, operation, cacheType, key string) (context.Context, trace.Span)
TraceCacheOperation instruments cache operations
func TraceMiddleware ¶
func TraceMiddleware(middlewareName string) gin.HandlerFunc
TraceMiddleware instrumenta middleware individual
func TraceRateLimitOperation ¶
func TraceRateLimitOperation(ctx context.Context, operation, limitType string, allowed bool) (context.Context, trace.Span)
TraceRateLimitOperation instruments rate limit operations
func TraceValidationOperation ¶
func TraceValidationOperation(ctx context.Context, validationType string, fieldCount int) (context.Context, trace.Span)
TraceValidationOperation instruments validation operations
func TraceWebSocketOperation ¶
func TraceWebSocketOperation(ctx context.Context, operation, connectionID string) (context.Context, trace.Span)
TraceWebSocketOperation instruments WebSocket operations
func TracingMiddleware ¶
func TracingMiddleware(config *TelemetryConfig) gin.HandlerFunc
TracingMiddleware main tracing middleware
func TracingStatsHandler ¶
func TracingStatsHandler() gin.HandlerFunc
TracingStatsHandler handler for tracing statistics
func ValidateGeneration ¶
ValidateGeneration validates if the generated file is correct
func ValidateJSON ¶
func ValidateJSON(target interface{}, config *ValidationConfig) gin.HandlerFunc
ValidateJSON middleware for automatic JSON validation
func ValidateParams ¶
func ValidateParams(rules map[string]string, config *ValidationConfig) gin.HandlerFunc
ValidateParams middleware for path parameter validation
func ValidateQuery ¶
func ValidateQuery(target interface{}, config *ValidationConfig) gin.HandlerFunc
ValidateQuery middleware for query parameter validation
func ValidateStruct ¶
func ValidateStruct(config *ValidationConfig) gin.HandlerFunc
ValidateStruct middleware for automatic struct validation
func WebSocketHandlerWrapper ¶
func WebSocketHandlerWrapper(handler WebSocketHandler) gin.HandlerFunc
WebSocketHandlerWrapper converts a WebSocketHandler to gin.HandlerFunc, allowing customization
func WebSocketStatsHandler ¶
func WebSocketStatsHandler() gin.HandlerFunc
WebSocketStatsHandler handler for WebSocket statistics
Types ¶
type CacheConfig ¶
type CacheConfig struct {
Type string `yaml:"type"` // "memory", "redis"
DefaultTTL string `yaml:"default_ttl"`
MaxSize int `yaml:"max_size,omitempty"`
Compression bool `yaml:"compression"`
}
CacheConfig cache system configuration
type CacheEntry ¶
type CacheEntry struct {
Data []byte `json:"data"`
Headers map[string]string `json:"headers"`
Status int `json:"status"`
ExpiresAt time.Time `json:"expires_at"`
}
CacheEntry represents a cache entry
type CacheKeyFunc ¶
CacheKeyFunc function to generate cache key
func ParseCacheArgs ¶
func ParseCacheArgs(args []string) (time.Duration, string, CacheKeyFunc)
ParseCacheArgs parses @Cache decorator arguments
type CacheStats ¶
type CacheStats struct {
Hits int64 `json:"hits"`
Misses int64 `json:"misses"`
Sets int64 `json:"sets"`
Deletes int64 `json:"deletes"`
Evictions int64 `json:"evictions"`
Size int64 `json:"size"`
MaxSize int64 `json:"max_size"`
HitRate float64 `json:"hit_rate"`
}
CacheStats cache statistics
type CacheStore ¶
type CacheStore interface {
Get(ctx context.Context, key string) (*CacheEntry, error)
Set(ctx context.Context, key string, entry *CacheEntry, ttl time.Duration) error
Delete(ctx context.Context, key string) error
Clear(ctx context.Context) error
Stats() CacheStats
}
CacheStore interface for different cache implementations
type CircuitBreaker ¶ added in v0.10.0
CircuitBreaker interface for circuit breaker pattern
type CircuitBreakerConfig ¶ added in v0.10.0
type CircuitBreakerConfig struct {
Enabled bool `yaml:"enabled"`
DefaultFailureThreshold int `yaml:"default_failure_threshold"`
DefaultRecoveryTimeout string `yaml:"default_recovery_timeout"`
}
CircuitBreakerConfig configuration for circuit breaker
type CircuitBreakerImpl ¶ added in v0.10.0
type CircuitBreakerImpl struct {
// contains filtered or unexported fields
}
CircuitBreakerImpl implements the circuit breaker pattern
func NewCircuitBreaker ¶ added in v0.10.0
func NewCircuitBreaker(failureThreshold int, recoveryTimeout time.Duration) *CircuitBreakerImpl
NewCircuitBreaker creates a new circuit breaker
func (*CircuitBreakerImpl) GetState ¶ added in v0.10.0
func (cb *CircuitBreakerImpl) GetState() string
GetState returns the current state as a string
func (*CircuitBreakerImpl) GetStats ¶ added in v0.10.0
func (cb *CircuitBreakerImpl) GetStats() map[string]interface{}
GetStats returns circuit breaker statistics
func (*CircuitBreakerImpl) IsOpen ¶ added in v0.10.0
func (cb *CircuitBreakerImpl) IsOpen() bool
IsOpen checks if the circuit breaker is open
func (*CircuitBreakerImpl) RecordFailure ¶ added in v0.10.0
func (cb *CircuitBreakerImpl) RecordFailure()
RecordFailure records a failed request
func (*CircuitBreakerImpl) RecordSuccess ¶ added in v0.10.0
func (cb *CircuitBreakerImpl) RecordSuccess()
RecordSuccess records a successful request
type CircuitBreakerState ¶ added in v0.10.0
type CircuitBreakerState int
CircuitBreakerState represents the state of a circuit breaker
const ( StateClosed CircuitBreakerState = iota StateOpen StateHalfOpen )
type ClientSDKConfig ¶
type ClientSDKConfig struct {
Enabled bool `yaml:"enabled"`
OutputDir string `yaml:"output_dir"`
Languages []string `yaml:"languages"` // "go", "python", "javascript", "typescript"
PackageName string `yaml:"package_name"`
ModuleName string `yaml:"module_name,omitempty"`
}
ClientSDKConfig SDK generation configuration
type Config ¶
type Config struct {
Version string `yaml:"version"`
Handlers HandlersConfig `yaml:"handlers"`
Generate GenerationConfig `yaml:"generation"`
Dev DevConfig `yaml:"dev"`
Prod ProdConfig `yaml:"prod"`
Redis RedisConfig `yaml:"redis,omitempty"`
Cache CacheConfig `yaml:"cache,omitempty"`
RateLimit RateLimitConfig `yaml:"rate_limit,omitempty"`
Metrics MetricsConfig `yaml:"metrics,omitempty"`
OpenAPI OpenAPIConfig `yaml:"openapi,omitempty"`
Validation ValidationConfig `yaml:"validation,omitempty"`
WebSocket WebSocketConfig `yaml:"websocket,omitempty"`
Telemetry TelemetryConfig `yaml:"telemetry,omitempty"`
ClientSDK ClientSDKConfig `yaml:"client_sdk,omitempty"`
Proxy ProxyConfigSettings `yaml:"proxy,omitempty"`
}
Config framework configuration structure
func LoadConfig ¶
LoadConfig loads configuration from file
func (*Config) DiscoverHandlers ¶
DiscoverHandlers discovers handler files based on configuration
type ConsulConfig ¶ added in v0.10.0
type ConsulConfig struct {
Enabled bool `yaml:"enabled"`
Address string `yaml:"address"`
Datacenter string `yaml:"datacenter"`
}
ConsulConfig configuration for Consul service discovery
type ConsulDiscovery ¶ added in v0.10.0
type ConsulDiscovery struct {
// contains filtered or unexported fields
}
ConsulDiscovery implements service discovery using Consul
func NewConsulDiscovery ¶ added in v0.10.0
func NewConsulDiscovery(address string) *ConsulDiscovery
NewConsulDiscovery creates a new Consul service discovery
func (*ConsulDiscovery) Discover ¶ added in v0.10.0
func (cd *ConsulDiscovery) Discover(service string) ([]*ProxyInstance, error)
Discover discovers service instances using Consul
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
Contact contact information
type DNSConfig ¶ added in v0.10.0
type DNSConfig struct {
Enabled bool `yaml:"enabled"`
}
DNSConfig configuration for DNS service discovery
type DNSDiscovery ¶ added in v0.10.0
type DNSDiscovery struct{}
DNSDiscovery implements service discovery using DNS
func NewDNSDiscovery ¶ added in v0.10.0
func NewDNSDiscovery() *DNSDiscovery
NewDNSDiscovery creates a new DNS service discovery
func (*DNSDiscovery) Discover ¶ added in v0.10.0
func (dd *DNSDiscovery) Discover(service string) ([]*ProxyInstance, error)
Discover discovers service instances using DNS
type Debouncer ¶
type Debouncer struct {
// contains filtered or unexported fields
}
Debouncer prevents too frequent regenerations
func NewDebouncer ¶
NewDebouncer creates a new debouncer
type Discriminator ¶
type Discriminator struct {
PropertyName string `json:"propertyName"`
Mapping map[string]string `json:"mapping,omitempty"`
}
Discriminator discriminator for polymorphism
type DocsData ¶
type DocsData struct {
Routes []RouteEntry
TotalRoutes int
UniqueMethods int
TotalMiddlewares int
}
DocsData structure to pass data to documentation template
type Encoding ¶
type Encoding struct {
ContentType string `json:"contentType,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
Style string `json:"style,omitempty"`
Explode bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
}
Encoding encoding
type EntityMeta ¶
type EntityMeta struct {
Name string `json:"name"`
PackageName string `json:"package_name"`
FileName string `json:"file_name"`
Markers []MarkerInstance `json:"markers"`
Fields []FieldMeta `json:"fields"`
// Documentation information
Description string `json:"description"`
Example map[string]interface{} `json:"example,omitempty"`
}
EntityMeta represents metadata of an entity/struct extracted from comments
type Example ¶
type Example struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
ExternalValue string `json:"externalValue,omitempty"`
}
Example exemplo
type ExternalDocs ¶
type ExternalDocs struct {
Description string `json:"description,omitempty"`
URL string `json:"url"`
}
ExternalDocs external documentation
type FieldMeta ¶
type FieldMeta struct {
Name string `json:"name"`
Type string `json:"type"`
JSONTag string `json:"json_tag"`
Description string `json:"description"`
Example interface{} `json:"example,omitempty"`
Validation string `json:"validation,omitempty"` // from validate tags
}
FieldMeta represents metadata of a struct field
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher monitors handler files and automatically regenerates code
var GlobalWatcher *FileWatcher
GlobalWatcher global file watcher instance
func NewFileWatcher ¶
func NewFileWatcher(config *Config) (*FileWatcher, error)
NewFileWatcher creates a new file watcher
func (*FileWatcher) IsRunning ¶
func (fw *FileWatcher) IsRunning() bool
IsRunning returns whether the watcher is running
type FrameworkStats ¶
type FrameworkStats struct {
TotalRoutes int `json:"total_routes"`
UniqueMiddlewares int `json:"unique_middlewares"`
PackagesScanned int `json:"packages_scanned"`
BuildMode string `json:"build_mode"` // "development" ou "production"
GeneratedAt string `json:"generated_at"`
Methods map[string]int `json:"methods"` // GET: 5, POST: 3, etc.
}
FrameworkStats statistics do framework
type GenData ¶
type GenData struct {
PackageName string // nome do pacote de destino
Routes []*RouteMeta // routes to be generated
Imports []string // necessary imports
Metadata map[string]interface{} // additional plugin data
GeneratedAt string // generation timestamp
}
GenData data passed to generation template
type GenerationConfig ¶
type GenerationConfig struct {
Template string `yaml:"template,omitempty"`
}
GenerationConfig configuration for code generation
type GeneratorHook ¶
GeneratorHook executed before code generation
func GetGeneratorHooks ¶
func GetGeneratorHooks() []GeneratorHook
GetGeneratorHooks returns all generator hooks (for testing)
type GoSDKGenerator ¶
type GoSDKGenerator struct{}
GoSDKGenerator generator for Go
func (*GoSDKGenerator) Generate ¶
func (g *GoSDKGenerator) Generate(spec *OpenAPISpec, config *ClientSDKConfig) error
Generate creates a Go client SDK from the OpenAPI specification
func (*GoSDKGenerator) GetFileExtension ¶
func (g *GoSDKGenerator) GetFileExtension() string
GetFileExtension retorna a extensão de arquivo para a linguagem.
func (*GoSDKGenerator) GetLanguage ¶
func (g *GoSDKGenerator) GetLanguage() string
GetLanguage retorna a linguagem de programação usada.
type GroupInfo ¶
type GroupInfo struct {
Name string `json:"name"`
Prefix string `json:"prefix"`
Description string `json:"description"`
}
GroupInfo represents information of a route group
func RegisterGroup ¶
RegisterGroup registers a new route group
type HTTPClientConfig ¶ added in v0.10.0
type HTTPClientConfig struct {
Timeout string `yaml:"timeout"`
MaxIdleConns int `yaml:"max_idle_conns"`
IdleConnTimeout string `yaml:"idle_conn_timeout"`
}
HTTPClientConfig configuration for HTTP client
type HandlersConfig ¶
HandlersConfig configuration for handlers discovery
type Header ¶
type Header struct {
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`
Style string `json:"style,omitempty"`
Explode bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
Schema *OpenAPISchema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
}
Header header
type HealthChecker ¶ added in v0.10.0
type HealthChecker interface {
Check(instance *ProxyInstance) bool
}
HealthChecker interface for health checking
type HealthCheckerImpl ¶ added in v0.10.0
type HealthCheckerImpl struct {
// contains filtered or unexported fields
}
HealthCheckerImpl implements health checking for service instances
func NewHealthChecker ¶ added in v0.10.0
func NewHealthChecker(config *ProxyConfig) *HealthCheckerImpl
NewHealthChecker creates a new health checker
func (*HealthCheckerImpl) Check ¶ added in v0.10.0
func (hc *HealthCheckerImpl) Check(instance *ProxyInstance) bool
Check performs a health check on the given instance
type IPHashLoadBalancer ¶ added in v0.10.0
type IPHashLoadBalancer struct{}
IPHashLoadBalancer implements IP hash load balancing
func (*IPHashLoadBalancer) Select ¶ added in v0.10.0
func (lb *IPHashLoadBalancer) Select(instances []*ProxyInstance, c *gin.Context) *ProxyInstance
Select selects instance based on client IP hash
type JavaScriptSDKGenerator ¶
type JavaScriptSDKGenerator struct{}
JavaScriptSDKGenerator generator for JavaScript
func (*JavaScriptSDKGenerator) Generate ¶
func (j *JavaScriptSDKGenerator) Generate(spec *OpenAPISpec, config *ClientSDKConfig) error
Generate creates a JavaScript client SDK from the OpenAPI specification
func (*JavaScriptSDKGenerator) GetFileExtension ¶
func (j *JavaScriptSDKGenerator) GetFileExtension() string
GetFileExtension retorna a extensão de arquivo para a linguagem.
func (*JavaScriptSDKGenerator) GetLanguage ¶
func (j *JavaScriptSDKGenerator) GetLanguage() string
GetLanguage retorna a linguagem de programação usada.
type K8sDiscovery ¶ added in v0.10.0
type K8sDiscovery struct {
// contains filtered or unexported fields
}
K8sDiscovery implements service discovery using Kubernetes
func NewK8sDiscovery ¶ added in v0.10.0
func NewK8sDiscovery(namespace string) *K8sDiscovery
NewK8sDiscovery creates a new Kubernetes service discovery
func (*K8sDiscovery) Discover ¶ added in v0.10.0
func (kd *K8sDiscovery) Discover(service string) ([]*ProxyInstance, error)
Discover discovers service instances using Kubernetes
type KeyGeneratorFunc ¶
KeyGeneratorFunc function to generate rate limiting keys
func ParseRateLimitArgs ¶
func ParseRateLimitArgs(args []string) (limit int, window time.Duration, rateLimiterType string, keyGen KeyGeneratorFunc)
ParseRateLimitArgs parses @RateLimit decorator arguments
type KubernetesConfig ¶ added in v0.10.0
type KubernetesConfig struct {
Enabled bool `yaml:"enabled"`
}
KubernetesConfig configuration for Kubernetes service discovery
type LeastConnectionsLoadBalancer ¶ added in v0.10.0
type LeastConnectionsLoadBalancer struct{}
LeastConnectionsLoadBalancer implements least connections load balancing
func (*LeastConnectionsLoadBalancer) Select ¶ added in v0.10.0
func (lb *LeastConnectionsLoadBalancer) Select(instances []*ProxyInstance, _ *gin.Context) *ProxyInstance
Select selects the instance with the least active connections
type Link ¶
type Link struct {
OperationRef string `json:"operationRef,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
RequestBody interface{} `json:"requestBody,omitempty"`
Description string `json:"description,omitempty"`
Server *OpenAPIServer `json:"server,omitempty"`
}
Link link to other operations
type LoadBalancer ¶ added in v0.10.0
type LoadBalancer interface {
Select(instances []*ProxyInstance, c *gin.Context) *ProxyInstance
}
LoadBalancer interface for different load balancing algorithms
type LoadBalancingConfig ¶ added in v0.10.0
type LoadBalancingConfig struct {
DefaultAlgorithm string `yaml:"default_algorithm"`
HealthCheckInterval string `yaml:"health_check_interval"`
HealthCheckTimeout string `yaml:"health_check_timeout"`
}
LoadBalancingConfig configuration for load balancing
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger controla o logging do framework
type MarkerConfig ¶
type MarkerConfig struct {
Name string // Marker name (ex: "Auth")
Pattern *regexp.Regexp // Regex to detect the marker
Factory func(args []string) gin.HandlerFunc // Factory to create middleware
Description string // Marker description
}
MarkerConfig configuration of a marker
type MarkerFactory ¶
type MarkerFactory func(args []string) gin.HandlerFunc
MarkerFactory function that creates a middleware based on arguments
type MarkerInstance ¶
type MarkerInstance struct {
Name string // Auth, Cache, etc.
Args []string // parsed arguments
Raw string // original comment text
}
MarkerInstance represents a marker instance found
type MediaType ¶
type MediaType struct {
Schema *OpenAPISchema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
Encoding map[string]Encoding `json:"encoding,omitempty"`
}
MediaType media type
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache in-memory cache implementation
func NewMemoryCache ¶
func NewMemoryCache(maxSize int) *MemoryCache
NewMemoryCache creates a new in-memory cache
func (*MemoryCache) Clear ¶
func (m *MemoryCache) Clear(ctx context.Context) error
Clear clears entire cache (in-memory implementation)
func (*MemoryCache) Delete ¶
func (m *MemoryCache) Delete(ctx context.Context, key string) error
Delete removes cache entry (in-memory implementation)
func (*MemoryCache) Get ¶
func (m *MemoryCache) Get(ctx context.Context, key string) (*CacheEntry, error)
Get retrieves cache entry (in-memory implementation)
func (*MemoryCache) Set ¶
func (m *MemoryCache) Set(ctx context.Context, key string, entry *CacheEntry, ttl time.Duration) error
Set stores cache entry (in-memory implementation)
func (*MemoryCache) Stats ¶
func (m *MemoryCache) Stats() CacheStats
Stats returns cache statistics (in-memory implementation)
type MemoryRateLimiter ¶
type MemoryRateLimiter struct {
// contains filtered or unexported fields
}
MemoryRateLimiter local in-memory implementation
func NewMemoryRateLimiter ¶
func NewMemoryRateLimiter() *MemoryRateLimiter
NewMemoryRateLimiter creates an in-memory rate limiter
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector collects custom metrics
func InitMetrics ¶
func InitMetrics(config *MetricsConfig) *MetricsCollector
InitMetrics initializes metrics system
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `yaml:"enabled"`
Endpoint string `yaml:"endpoint"`
Namespace string `yaml:"namespace"`
Subsystem string `yaml:"subsystem"`
Buckets []float64 `yaml:"buckets,omitempty"`
}
MetricsConfig Prometheus configuration
type MetricsInfo ¶
type MetricsInfo struct {
Enabled bool `json:"enabled"`
Endpoint string `json:"endpoint"`
Namespace string `json:"namespace"`
Subsystem string `json:"subsystem"`
Metrics []string `json:"metrics"`
}
MetricsInfo information about available metrics
func GetMetricsInfo ¶
func GetMetricsInfo(config *MetricsConfig) MetricsInfo
GetMetricsInfo returns information about metrics
type MiddlewareInfo ¶
type MiddlewareInfo struct {
Name string `json:"name"`
Args map[string]interface{} `json:"args"`
Order int `json:"order"`
Description string `json:"description"`
}
MiddlewareInfo information about middlewares aplicados
type MultipleValidationError ¶
type MultipleValidationError struct {
Errors []ValidationError
}
MultipleValidationError represents multiple validation errors
func (*MultipleValidationError) Error ¶
func (e *MultipleValidationError) Error() string
type OAuthFlow ¶
type OAuthFlow struct {
AuthorizationURL string `json:"authorizationUrl,omitempty"`
TokenURL string `json:"tokenUrl,omitempty"`
RefreshURL string `json:"refreshUrl,omitempty"`
Scopes map[string]string `json:"scopes"`
}
OAuthFlow fluxo OAuth2
type OAuthFlows ¶
type OAuthFlows struct {
Implicit *OAuthFlow `json:"implicit,omitempty"`
Password *OAuthFlow `json:"password,omitempty"`
ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty"`
AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty"`
}
OAuthFlows fluxos OAuth2
type OpenAPIComponents ¶
type OpenAPIComponents struct {
Schemas map[string]*OpenAPISchema `json:"schemas,omitempty"`
Responses map[string]OpenAPIResponse `json:"responses,omitempty"`
Parameters map[string]OpenAPIParameter `json:"parameters,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
RequestBodies map[string]OpenAPIRequestBody `json:"requestBodies,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
Links map[string]Link `json:"links,omitempty"`
Callbacks map[string]interface{} `json:"callbacks,omitempty"`
}
OpenAPIComponents reusable components
type OpenAPIConfig ¶
type OpenAPIConfig struct {
Version string `yaml:"version"`
Title string `yaml:"title"`
Description string `yaml:"description"`
Host string `yaml:"host"`
BasePath string `yaml:"base_path"`
Schemes []string `yaml:"schemes"`
Contact map[string]interface{} `yaml:"contact,omitempty"`
License map[string]interface{} `yaml:"license,omitempty"`
Security []map[string][]string `yaml:"security,omitempty"`
}
OpenAPIConfig OpenAPI documentation configuration
type OpenAPIInfo ¶
type OpenAPIInfo struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact *Contact `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
Version string `json:"version"`
}
OpenAPIInfo basic API information
type OpenAPIOperation ¶
type OpenAPIOperation struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters []OpenAPIParameter `json:"parameters,omitempty"`
RequestBody *OpenAPIRequestBody `json:"requestBody,omitempty"`
Responses map[string]OpenAPIResponse `json:"responses"`
Callbacks map[string]interface{} `json:"callbacks,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Security []SecurityRequirement `json:"security,omitempty"`
Servers []OpenAPIServer `json:"servers,omitempty"`
Extensions map[string]interface{} `json:"-"`
}
OpenAPIOperation individual operation
type OpenAPIParameter ¶
type OpenAPIParameter struct {
Name string `json:"name"`
In string `json:"in"` // query, header, path, cookie
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`
Style string `json:"style,omitempty"`
Explode bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
Schema *OpenAPISchema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
}
OpenAPIParameter operation parameter
type OpenAPIPath ¶
type OpenAPIPath map[string]*OpenAPIOperation
OpenAPIPath operations available on a path
type OpenAPIRequestBody ¶
type OpenAPIRequestBody struct {
Description string `json:"description,omitempty"`
Content map[string]MediaType `json:"content"`
Required bool `json:"required,omitempty"`
}
OpenAPIRequestBody corpo da request
type OpenAPIResponse ¶
type OpenAPIResponse struct {
Description string `json:"description"`
Headers map[string]Header `json:"headers,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
Links map[string]Link `json:"links,omitempty"`
}
OpenAPIResponse operation response
type OpenAPISchema ¶
type OpenAPISchema struct {
Type string `json:"type,omitempty"`
AllOf []*OpenAPISchema `json:"allOf,omitempty"`
OneOf []*OpenAPISchema `json:"oneOf,omitempty"`
AnyOf []*OpenAPISchema `json:"anyOf,omitempty"`
Not *OpenAPISchema `json:"not,omitempty"`
Items *OpenAPISchema `json:"items,omitempty"`
Properties map[string]*OpenAPISchema `json:"properties,omitempty"`
AdditionalProperties interface{} `json:"additionalProperties,omitempty"`
Description string `json:"description,omitempty"`
Format string `json:"format,omitempty"`
Default interface{} `json:"default,omitempty"`
Title string `json:"title,omitempty"`
MultipleOf float64 `json:"multipleOf,omitempty"`
Maximum float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
Minimum float64 `json:"minimum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
MaxLength int `json:"maxLength,omitempty"`
MinLength int `json:"minLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
MaxItems int `json:"maxItems,omitempty"`
MinItems int `json:"minItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
MaxProperties int `json:"maxProperties,omitempty"`
MinProperties int `json:"minProperties,omitempty"`
Required []string `json:"required,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Example interface{} `json:"example,omitempty"`
Nullable bool `json:"nullable,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
WriteOnly bool `json:"writeOnly,omitempty"`
XML *XML `json:"xml,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Discriminator *Discriminator `json:"discriminator,omitempty"`
Ref string `json:"$ref,omitempty"`
}
OpenAPISchema data schema
type OpenAPIServer ¶
type OpenAPIServer struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
Variables map[string]ServerVariable `json:"variables,omitempty"`
}
OpenAPIServer server information
type OpenAPISpec ¶
type OpenAPISpec struct {
OpenAPI string `json:"openapi"`
Info OpenAPIInfo `json:"info"`
Servers []OpenAPIServer `json:"servers,omitempty"`
Paths map[string]OpenAPIPath `json:"paths"`
Components *OpenAPIComponents `json:"components,omitempty"`
Security []SecurityRequirement `json:"security,omitempty"`
Tags []OpenAPITag `json:"tags,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}
OpenAPISpec complete OpenAPI 3.0 specification structure
func GenerateOpenAPISpec ¶
func GenerateOpenAPISpec(config *Config) *OpenAPISpec
GenerateOpenAPISpec generates complete OpenAPI 3.0 specification
type OpenAPITag ¶
type OpenAPITag struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}
OpenAPITag tag for grouping
type ParameterInfo ¶
type ParameterInfo struct {
Name string `json:"name"`
Type string `json:"type"` // string, int, bool, etc.
Location string `json:"location"` // query, path, body, header
Required bool `json:"required"`
Description string `json:"description"`
Example string `json:"example"`
}
ParameterInfo represents information of a route parameter
type ParserHook ¶
ParserHook executed after parsing routes
func GetParserHooks ¶
func GetParserHooks() []ParserHook
GetParserHooks returns all parser hooks (for testing)
type ParserStats ¶
type ParserStats struct {
FilesProcessed int `json:"files_processed"`
RoutesFound int `json:"routes_found"`
MarkersApplied int `json:"markers_applied"`
Errors []ValidationError `json:"errors"`
Warnings []ValidationError `json:"warnings"`
ProcessingTime string `json:"processing_time"`
SourceDirectory string `json:"source_directory"`
}
ParserStats statistics do processo de parsing
type ProdConfig ¶
ProdConfig configuration for production mode
type PropertyInfo ¶
type PropertyInfo struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Example interface{} `json:"example,omitempty"`
Required bool `json:"required"`
Enum []string `json:"enum,omitempty"`
MinLength *int `json:"min_length,omitempty"`
MaxLength *int `json:"max_length,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
Items *PropertyInfo `json:"items,omitempty"` // For array types
Ref string `json:"$ref,omitempty"` // For schema references
}
PropertyInfo information about a schema property
type ProxyConfig ¶ added in v0.10.0
type ProxyConfig struct {
// Service Discovery
Target string `json:"target"` // Direct URL
Service string `json:"service"` // Service name for discovery
Discovery string `json:"discovery"` // dns, consul, kubernetes, static
Targets []string `json:"targets"` // List of URLs for static discovery
// Load Balancing
LoadBalancer string `json:"load_balancer"` // round_robin, least_connections, ip_hash, weighted
HealthCheck string `json:"health_check"` // Health check endpoint
HealthInterval string `json:"health_interval"` // Health check interval
// Resilience
Timeout string `json:"timeout"`
Retries int `json:"retries"`
RetryBackoff string `json:"retry_backoff"` // linear, exponential
RetryDelay string `json:"retry_delay"`
// Circuit Breaker
CircuitBreaker string `json:"circuit_breaker"`
FailureThreshold int `json:"failure_threshold"`
// Advanced
Path string `json:"path"`
Headers map[string]string `json:"headers"`
Transform string `json:"transform"` // Request/response transformation
// Service Discovery specific
ConsulAddress string `json:"consul_address"`
K8sNamespace string `json:"k8s_namespace"`
}
ProxyConfig configuration for proxy middleware
type ProxyConfigSettings ¶ added in v0.10.0
type ProxyConfigSettings struct {
Enabled bool `yaml:"enabled"`
// Service Discovery
ServiceDiscovery ServiceDiscoveryConfig `yaml:"service_discovery"`
// Load Balancing
LoadBalancing LoadBalancingConfig `yaml:"load_balancing"`
// Circuit Breaker
CircuitBreaker CircuitBreakerConfig `yaml:"circuit_breaker"`
// Retry
Retry RetryConfig `yaml:"retry"`
// HTTP Client
HTTPClient HTTPClientConfig `yaml:"http_client"`
}
ProxyConfigSettings configuration for proxy functionality
type ProxyInstance ¶ added in v0.10.0
type ProxyInstance struct {
URL string `json:"url"`
Weight int `json:"weight"`
Healthy bool `json:"healthy"`
LastCheck time.Time `json:"last_check"`
ActiveConns int `json:"active_conns"`
FailureCount int `json:"failure_count"`
Metadata map[string]string `json:"metadata"`
// contains filtered or unexported fields
}
ProxyInstance represents a service instance
type ProxyManager ¶ added in v0.10.0
type ProxyManager struct {
// contains filtered or unexported fields
}
ProxyManager manages proxy operations
func NewProxyManager ¶ added in v0.10.0
func NewProxyManager(config *ProxyConfig) *ProxyManager
NewProxyManager creates a new proxy manager
func (*ProxyManager) Forward ¶ added in v0.10.0
func (pm *ProxyManager) Forward(c *gin.Context, config *ProxyConfig)
Forward forwards the request to the selected instance
type PythonSDKGenerator ¶
type PythonSDKGenerator struct{}
PythonSDKGenerator generator for Python
func (*PythonSDKGenerator) Generate ¶
func (p *PythonSDKGenerator) Generate(spec *OpenAPISpec, config *ClientSDKConfig) error
Generate creates a Python client SDK from the OpenAPI specification
func (*PythonSDKGenerator) GetFileExtension ¶
func (p *PythonSDKGenerator) GetFileExtension() string
GetFileExtension retorna a extensão de arquivo para a linguagem.
func (*PythonSDKGenerator) GetLanguage ¶
func (p *PythonSDKGenerator) GetLanguage() string
GetLanguage retorna a linguagem de programação usada.
type RateLimitConfig ¶
type RateLimitConfig struct {
Enabled bool `yaml:"enabled"`
Type string `yaml:"type"` // "memory", "redis"
DefaultRPS int `yaml:"default_rps"`
BurstSize int `yaml:"burst_size"`
KeyFunc string `yaml:"key_func"` // "ip", "user", "custom"
}
RateLimitConfig rate limiting configuration
type RateLimitResponse ¶
type RateLimitResponse struct {
Error string `json:"error"`
Message string `json:"message"`
Limit int `json:"limit"`
Remaining int `json:"remaining"`
RetryAfter int `json:"retry_after"`
}
RateLimitResponse response when rate limit is exceeded
type RateLimiter ¶
type RateLimiter interface {
Allow(ctx context.Context, key string, limit int, window time.Duration) (bool, int, time.Duration, error)
Reset(ctx context.Context, key string) error
}
RateLimiter interface for different rate limiting implementations
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache Redis cache implementation
func NewRedisCache ¶
func NewRedisCache(config RedisConfig, prefix string) (*RedisCache, error)
NewRedisCache creates a new Redis cache
func (*RedisCache) Clear ¶
func (r *RedisCache) Clear(ctx context.Context) error
Clear clears entire cache (Redis implementation)
func (*RedisCache) Delete ¶
func (r *RedisCache) Delete(ctx context.Context, key string) error
Delete removes cache entry (Redis implementation)
func (*RedisCache) Get ¶
func (r *RedisCache) Get(ctx context.Context, key string) (*CacheEntry, error)
Get retrieves cache entry (Redis implementation)
func (*RedisCache) Set ¶
func (r *RedisCache) Set(ctx context.Context, key string, entry *CacheEntry, ttl time.Duration) error
Set stores cache entry (Redis implementation)
func (*RedisCache) Stats ¶
func (r *RedisCache) Stats() CacheStats
Stats returns cache statistics (Redis implementation)
type RedisConfig ¶
type RedisConfig struct {
Enabled bool `yaml:"enabled"`
Address string `yaml:"address"`
Password string `yaml:"password,omitempty"`
DB int `yaml:"db"`
PoolSize int `yaml:"pool_size"`
}
RedisConfig Redis configuration
type RedisRateLimiter ¶
type RedisRateLimiter struct {
// contains filtered or unexported fields
}
RedisRateLimiter distributed implementation with Redis
func NewRedisRateLimiter ¶
func NewRedisRateLimiter(config RedisConfig) (*RedisRateLimiter, error)
NewRedisRateLimiter creates a distributed rate limiter with Redis
type ResponseInfo ¶
type ResponseInfo struct {
Code string `json:"code"` // HTTP status code (200, 404, etc.)
Description string `json:"description"` // Response description
Type string `json:"type"` // Schema type name (UserResponse, ErrorResponse, etc.)
Example string `json:"example"` // Response example
}
ResponseInfo represents information of a route response
type RetryConfig ¶ added in v0.10.0
type RetryConfig struct {
DefaultAttempts int `yaml:"default_attempts"`
DefaultBackoff string `yaml:"default_backoff"`
DefaultDelay string `yaml:"default_delay"`
}
RetryConfig configuration for retry logic
type RoundRobinLoadBalancer ¶ added in v0.10.0
type RoundRobinLoadBalancer struct {
// contains filtered or unexported fields
}
RoundRobinLoadBalancer implements round-robin load balancing
func (*RoundRobinLoadBalancer) Select ¶ added in v0.10.0
func (lb *RoundRobinLoadBalancer) Select(instances []*ProxyInstance, _ *gin.Context) *ProxyInstance
Select selects the next instance in round-robin fashion
type Route ¶
type Route struct {
Method string `json:"method"`
Path string `json:"path"`
Handler gin.HandlerFunc `json:"-"`
Middlewares []gin.HandlerFunc `json:"-"`
}
Route represents a route extracted from parsing
type RouteEntry ¶
type RouteEntry struct {
Method string `json:"method"`
Path string `json:"path"`
Handler gin.HandlerFunc `json:"-"`
Middlewares []gin.HandlerFunc `json:"-"`
FuncName string `json:"func_name"`
PackageName string `json:"package_name"`
FileName string `json:"file_name"`
Description string `json:"description"`
Summary string `json:"summary"`
Tags []string `json:"tags"`
MiddlewareInfo []MiddlewareInfo `json:"middleware_info"`
Parameters []ParameterInfo `json:"parameters"`
Group *GroupInfo `json:"group,omitempty"`
Responses []ResponseInfo `json:"responses,omitempty"` // Updated to use ResponseInfo
WebSocketHandlers []string `json:"websocketHandlers,omitempty"` // WebSocket message types this function handles
}
RouteEntry represents complete information about a route
func GetRoutes ¶
func GetRoutes() []RouteEntry
GetRoutes returns all registered routes (used for documentation)
type RouteMeta ¶
type RouteMeta struct {
Method string // GET, POST, etc.
Path string // /api/users
FuncName string // GetUsers
PackageName string // handlers
FileName string // user_handlers.go
Markers []MarkerInstance // found marker instances
MiddlewareCalls []string // generated middleware calls
// Documentation information
Description string `json:"description"`
Summary string `json:"summary"`
Tags []string `json:"tags"`
MiddlewareInfo []MiddlewareInfo `json:"middlewareInfo"`
Parameters []ParameterInfo `json:"parameters"`
Group *GroupInfo `json:"group,omitempty"`
Responses []ResponseInfo `json:"responses,omitempty"` // Updated to use ResponseInfo
WebSocketHandlers []string `json:"websocketHandlers,omitempty"` // WebSocket message types this function handles
}
RouteMeta represents metadata of a route extracted from comments
func ParseDirectory ¶
ParseDirectory analyzes a directory and extracts route metadata
type SDKGenerator ¶
type SDKGenerator interface {
Generate(spec *OpenAPISpec, config *ClientSDKConfig) error
GetLanguage() string
GetFileExtension() string
}
SDKGenerator interface for different SDK generators
type SDKManager ¶
type SDKManager struct {
// contains filtered or unexported fields
}
SDKManager manages SDK generation
func NewSDKManager ¶
func NewSDKManager(config *ClientSDKConfig) *SDKManager
NewSDKManager creates new SDK manager
func (*SDKManager) GenerateSDKs ¶
func (sm *SDKManager) GenerateSDKs(spec *OpenAPISpec) error
GenerateSDKs generates SDKs for all configured languages
func (*SDKManager) RegisterGenerator ¶
func (sm *SDKManager) RegisterGenerator(language string, generator SDKGenerator)
RegisterGenerator registers new generator
type SchemaInfo ¶
type SchemaInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"` // "object", "array", etc.
Properties map[string]*PropertyInfo `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Example interface{} `json:"example,omitempty"`
PackageName string `json:"package_name"`
FileName string `json:"file_name"`
}
SchemaInfo information about a registered schema/entity
func GetSchema ¶
func GetSchema(name string) *SchemaInfo
GetSchema returns a specific schema by name
type SecurityConfig ¶ added in v0.10.0
type SecurityConfig struct {
// Allowed networks in CIDR notation (e.g., "192.168.1.0/24", "10.0.0.0/8")
AllowedNetworks []string
// Allowed IP addresses (individual IPs)
AllowedIPs []string
// Allowed hostnames/domains
AllowedHosts []string
// Whether to allow localhost/127.0.0.1
AllowLocalhost bool
// Whether to allow private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
AllowPrivateNetworks bool
// Custom error message
ErrorMessage string
// Whether to log blocked attempts
LogBlockedAttempts bool
}
SecurityConfig holds security configuration for internal endpoints
func DefaultSecurityConfig ¶ added in v0.10.0
func DefaultSecurityConfig() *SecurityConfig
DefaultSecurityConfig returns a secure default configuration
type SecurityRequirement ¶
SecurityRequirement security requirement
type SecurityScheme ¶
type SecurityScheme struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
Flows *OAuthFlows `json:"flows,omitempty"`
OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"`
}
SecurityScheme security scheme
type ServerVariable ¶
type ServerVariable struct {
Enum []string `json:"enum,omitempty"`
Default string `json:"default"`
Description string `json:"description,omitempty"`
}
ServerVariable server variable
type ServiceDiscovery ¶ added in v0.10.0
type ServiceDiscovery interface {
Discover(service string) ([]*ProxyInstance, error)
}
ServiceDiscovery interface for different discovery methods
type ServiceDiscoveryConfig ¶ added in v0.10.0
type ServiceDiscoveryConfig struct {
Consul ConsulConfig `yaml:"consul"`
Kubernetes KubernetesConfig `yaml:"kubernetes"`
DNS DNSConfig `yaml:"dns"`
}
ServiceDiscoveryConfig configuration for service discovery
type StaticDiscovery ¶ added in v0.10.0
type StaticDiscovery struct {
// contains filtered or unexported fields
}
StaticDiscovery implements static service discovery
func NewStaticDiscovery ¶ added in v0.10.0
func NewStaticDiscovery(targets []string) *StaticDiscovery
NewStaticDiscovery creates a new static service discovery
func (*StaticDiscovery) Discover ¶ added in v0.10.0
func (sd *StaticDiscovery) Discover(_ string) ([]*ProxyInstance, error)
Discover returns the static targets as instances
type TelemetryConfig ¶
type TelemetryConfig struct {
Enabled bool `yaml:"enabled"`
ServiceName string `yaml:"service_name"`
ServiceVersion string `yaml:"service_version"`
Environment string `yaml:"environment"`
Endpoint string `yaml:"endpoint"`
Insecure bool `yaml:"insecure"`
SampleRate float64 `yaml:"sample_rate"`
}
TelemetryConfig OpenTelemetry configuration
type TelemetryManager ¶
type TelemetryManager struct {
// contains filtered or unexported fields
}
TelemetryManager manages OpenTelemetry configuration and instrumentation
func InitTelemetry ¶
func InitTelemetry(config *TelemetryConfig) (*TelemetryManager, error)
InitTelemetry initializes OpenTelemetry
type TokenBucket ¶
type TokenBucket struct {
// contains filtered or unexported fields
}
TokenBucket represents a token bucket
type TracingInfo ¶
type TracingInfo struct {
Enabled bool `json:"enabled"`
ServiceName string `json:"service_name"`
ServiceVersion string `json:"service_version"`
Environment string `json:"environment"`
Endpoint string `json:"endpoint"`
SampleRate float64 `json:"sample_rate"`
Attributes map[string]string `json:"attributes"`
}
TracingInfo information about tracing for documentation
func GetTracingInfo ¶
func GetTracingInfo(config *TelemetryConfig) TracingInfo
GetTracingInfo returns information about tracing configuration
type TypeScriptSDKGenerator ¶
type TypeScriptSDKGenerator struct{}
TypeScriptSDKGenerator generator for TypeScript
func (*TypeScriptSDKGenerator) Generate ¶
func (t *TypeScriptSDKGenerator) Generate(spec *OpenAPISpec, config *ClientSDKConfig) error
Generate creates a TypeScript client SDK from the OpenAPI specification
func (*TypeScriptSDKGenerator) GetFileExtension ¶
func (t *TypeScriptSDKGenerator) GetFileExtension() string
GetFileExtension retorna a extensão de arquivo para a linguagem.
func (*TypeScriptSDKGenerator) GetLanguage ¶
func (t *TypeScriptSDKGenerator) GetLanguage() string
GetLanguage retorna a linguagem de programação usada.
type ValidationConfig ¶
type ValidationConfig struct {
Enabled bool `yaml:"enabled"`
FailFast bool `yaml:"fail_fast"`
CustomTags []string `yaml:"custom_tags,omitempty"`
ErrorFormat string `yaml:"error_format"`
TranslateFunc string `yaml:"translate_func,omitempty"`
}
ValidationConfig validation configuration
type ValidationError ¶
type ValidationError struct {
File string `json:"file"`
Line int `json:"line"`
Message string `json:"message"`
Code string `json:"code"`
}
ValidationError validation error during parsing or generation
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationField ¶
type ValidationField struct {
Field string `json:"field"`
Value string `json:"value"`
Tag string `json:"tag"`
Message string `json:"message"`
Param string `json:"param,omitempty"`
}
ValidationField field-specific error
type ValidationResponse ¶
type ValidationResponse struct {
Error string `json:"error"`
Message string `json:"message"`
Fields []ValidationField `json:"fields,omitempty"`
Details map[string]interface{} `json:"details,omitempty"`
}
ValidationResponse validation error response
type WebSocketConfig ¶
type WebSocketConfig struct {
Enabled bool `yaml:"enabled"`
ReadBuffer int `yaml:"read_buffer"`
WriteBuffer int `yaml:"write_buffer"`
CheckOrigin bool `yaml:"check_origin"`
Compression bool `yaml:"compression"`
PingInterval string `yaml:"ping_interval"`
PongTimeout string `yaml:"pong_timeout"`
}
WebSocketConfig WebSocket configuration
type WebSocketConnection ¶
type WebSocketConnection struct {
ID string
Conn *websocket.Conn
Send chan []byte
Hub *WebSocketHub
UserID string
Groups map[string]bool
Metadata map[string]interface{}
// contains filtered or unexported fields
}
WebSocketConnection represents a WebSocket connection
type WebSocketHandler ¶
type WebSocketHandler func(conn *WebSocketConnection, message *WebSocketMessage) error
WebSocketHandler handler type for WebSocket messages
type WebSocketHub ¶
type WebSocketHub struct {
// contains filtered or unexported fields
}
WebSocketHub manages WebSocket connections
func GetWebSocketHub ¶
func GetWebSocketHub() *WebSocketHub
GetWebSocketHub returns the default WebSocket hub for direct access
func InitWebSocket ¶
func InitWebSocket(config WebSocketConfig) *WebSocketHub
InitWebSocket initializes the WebSocket system
func (*WebSocketHub) Broadcast ¶
func (h *WebSocketHub) Broadcast(message *WebSocketMessage)
Broadcast sends message to all connections
func (*WebSocketHub) JoinGroup ¶
func (h *WebSocketHub) JoinGroup(connID, groupName string) error
JoinGroup adds connection to a group
func (*WebSocketHub) LeaveGroup ¶
func (h *WebSocketHub) LeaveGroup(connID, groupName string) error
LeaveGroup removes connection from a group
func (*WebSocketHub) SendToConnection ¶
func (h *WebSocketHub) SendToConnection(connID string, message *WebSocketMessage)
SendToConnection sends message to specific connection
func (*WebSocketHub) SendToGroup ¶
func (h *WebSocketHub) SendToGroup(groupName string, message *WebSocketMessage)
SendToGroup sends message to group
type WebSocketMessage ¶
type WebSocketMessage struct {
Type string `json:"type"`
Data interface{} `json:"data"`
Sender string `json:"sender,omitempty"`
Target string `json:"target,omitempty"` // ID of specific connection
Group string `json:"group,omitempty"` // Group name
Timestamp time.Time `json:"timestamp"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
WebSocketMessage represents a WebSocket message
func (*WebSocketMessage) ToJSON ¶
func (m *WebSocketMessage) ToJSON() string
ToJSON converts message to JSON
type WebSocketRouter ¶
type WebSocketRouter struct {
// contains filtered or unexported fields
}
WebSocketRouter router for WebSocket messages
func (*WebSocketRouter) HandleMessage ¶
func (r *WebSocketRouter) HandleMessage(conn *WebSocketConnection, message *WebSocketMessage)
HandleMessage processes message using registered handlers
func (*WebSocketRouter) RegisterHandler ¶
func (r *WebSocketRouter) RegisterHandler(messageType string, handler WebSocketHandler)
RegisterHandler registers handler for message type
type WeightedRoundRobinLoadBalancer ¶ added in v0.10.0
type WeightedRoundRobinLoadBalancer struct {
// contains filtered or unexported fields
}
WeightedRoundRobinLoadBalancer implements weighted round-robin load balancing
func (*WeightedRoundRobinLoadBalancer) Select ¶ added in v0.10.0
func (lb *WeightedRoundRobinLoadBalancer) Select(instances []*ProxyInstance, _ *gin.Context) *ProxyInstance
Select selects instance based on weighted round-robin
Source Files
¶
- cache.go
- circuit_breaker.go
- client_sdk.go
- config.go
- docs_handler.go
- generator.go
- health_checker.go
- load_balancer.go
- logging.go
- markers.go
- metrics.go
- minifier.go
- openapi.go
- parser.go
- plugin.go
- proxy.go
- rate_limiting.go
- registry.go
- runtime.go
- schemas.go
- security.go
- service_discovery.go
- telemetry.go
- test_helpers.go
- types.go
- validation.go
- watcher.go
- websocket.go