Documentation
¶
Index ¶
- func CacheMiddleware(config *CacheConfig) func(http.Handler) http.Handler
- func RunServer(cfg *ServerConfig) error
- func TenantMiddleware(next http.Handler) http.Handler
- func VersionMiddleware(manager *VersionManager) func(http.Handler) http.Handler
- type AnomalySummary
- type BehavioralAnalysisStats
- type Cache
- type CacheConfig
- type CacheHandler
- type CacheInvalidator
- func (i *CacheInvalidator) AddRule(pattern string, tags []string) error
- func (i *CacheInvalidator) InvalidateByPattern(ctx context.Context, pattern string) error
- func (i *CacheInvalidator) InvalidateByTag(ctx context.Context, tag string) error
- func (i *CacheInvalidator) InvalidateKey(ctx context.Context, key string) error
- type CacheKeyGenerator
- type CacheStats
- type CacheStore
- type CacheWarmer
- type ContentAnalysisStats
- type ETagger
- type InMemoryCache
- func (c *InMemoryCache) Clear(ctx context.Context) error
- func (c *InMemoryCache) Delete(ctx context.Context, key string) error
- func (c *InMemoryCache) Exists(ctx context.Context, key string) (bool, error)
- func (c *InMemoryCache) Get(ctx context.Context, key string) (*Cache, error)
- func (c *InMemoryCache) InvalidateByTag(ctx context.Context, tag string) error
- func (c *InMemoryCache) Set(ctx context.Context, key string, cache *Cache) error
- func (c *InMemoryCache) Stats(ctx context.Context) (CacheStats, error)
- type InvalidationRule
- type JSONCacheValue
- type LastModifiedHandler
- type MLStatsHandler
- func (h *MLStatsHandler) HandleGetStats(w http.ResponseWriter, r *http.Request)
- func (h *MLStatsHandler) HandleHealth(w http.ResponseWriter, r *http.Request)
- func (h *MLStatsHandler) HandleResetStats(w http.ResponseWriter, r *http.Request)
- func (h *MLStatsHandler) HandleUpdateConfig(w http.ResponseWriter, r *http.Request)
- func (h *MLStatsHandler) RegisterRoutes(mux *http.ServeMux)
- type MLStatsResponse
- type MiddlewareStats
- type NegotiationResult
- type PrefetchRequest
- type PromptInjectionStats
- type Server
- func (s *Server) AddRoute(version, method, path string, handler http.Handler)
- func (s *Server) AddRouteFunc(version, method, path string, fn func(http.ResponseWriter, *http.Request))
- func (s *Server) Router() *VersionedRouter
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Start() error
- func (s *Server) Stop() error
- func (s *Server) UseMiddleware(middleware func(http.Handler) http.Handler)
- type ServerConfig
- type TenantAPIHandler
- func (h *TenantAPIHandler) ActivateTenant(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) CreateTenant(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) DeleteTenant(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) ExportTenantAuditLog(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) GetTenant(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) GetTenantAuditLog(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) GetTenantCompliance(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) GetTenantQuota(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) ListTenants(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) RegisterRoutes(mux *http.ServeMux)
- func (h *TenantAPIHandler) SuspendTenant(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) UpdateTenant(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) UpdateTenantCompliance(w http.ResponseWriter, r *http.Request)
- func (h *TenantAPIHandler) UpdateTenantQuota(w http.ResponseWriter, r *http.Request)
- type VaryCacheKeyGenerator
- type Version
- type VersionConfig
- type VersionHandler
- type VersionList
- type VersionManager
- func (m *VersionManager) GetDefaultVersion() string
- func (m *VersionManager) GetDeprecationWarning(version string) (string, bool)
- func (m *VersionManager) GetSupportedVersions() []string
- func (m *VersionManager) GetVersion(version string) (*Version, bool)
- func (m *VersionManager) RegisterDeprecated(deprecated, replacement string, sunset time.Time)
- func (m *VersionManager) RegisterUnsupported(version string)
- func (m *VersionManager) RegisterVersion(v *Version)
- func (m *VersionManager) SetDefaultVersion(version string)
- type VersionNegotiator
- type VersionedRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheMiddleware ¶
func CacheMiddleware(config *CacheConfig) func(http.Handler) http.Handler
CacheMiddleware creates caching middleware
func RunServer ¶
func RunServer(cfg *ServerConfig) error
RunServer runs the server with signal handling
func TenantMiddleware ¶
TenantMiddleware extracts tenant ID from request and adds to context
func VersionMiddleware ¶
func VersionMiddleware(manager *VersionManager) func(http.Handler) http.Handler
VersionMiddleware creates middleware for version handling
Types ¶
type AnomalySummary ¶
type AnomalySummary struct {
Type string `json:"type"`
Severity int `json:"severity"`
Score float64 `json:"score"`
ClientIP string `json:"client_ip"`
Path string `json:"path"`
Method string `json:"method"`
Timestamp time.Time `json:"timestamp"`
Blocked bool `json:"blocked"`
}
AnomalySummary represents a summary of a detected anomaly
type BehavioralAnalysisStats ¶
type BehavioralAnalysisStats struct {
TotalClients int64 `json:"total_clients"`
AnomalousClients int64 `json:"anomalous_clients"`
TotalAnomalies int64 `json:"total_anomalies"`
ActiveClients int `json:"active_clients"`
}
BehavioralAnalysisStats holds behavioral analysis stats
type Cache ¶
type Cache struct {
Key string
Value []byte
Headers http.Header
Expiry time.Time
CreatedAt time.Time
Tags []string
StatusCode int
}
Cache represents a cacheable response
type CacheConfig ¶
type CacheConfig struct {
// TTL is the default time-to-live for cached responses
TTL time.Duration
// MaxAge is the max-age for Cache-Control header
MaxAge time.Duration
// StaleWhileRevalidate allows serving stale content while revalidating
StaleWhileRevalidate time.Duration
// StaleWhileError allows serving stale content on errors
StaleWhileError time.Duration
// VaryHeaders specifies headers that affect caching
VaryHeaders []string
// CacheableMethods specifies which HTTP methods can be cached
CacheableMethods []string
// CacheableStatusCodes specifies which status codes can be cached
CacheableStatusCodes []int
// Tags for cache invalidation
Tags []string
// Store is the cache storage backend
Store CacheStore
}
CacheConfig contains cache configuration
func DefaultCacheConfig ¶
func DefaultCacheConfig() *CacheConfig
DefaultCacheConfig returns default cache configuration
type CacheHandler ¶
type CacheHandler struct {
// contains filtered or unexported fields
}
CacheHandler handles HTTP caching
func NewCacheHandler ¶
func NewCacheHandler(config *CacheConfig) *CacheHandler
NewCacheHandler creates a new cache handler
func (*CacheHandler) Handle ¶
func (h *CacheHandler) Handle(handler http.Handler) http.Handler
Handle caches and serves HTTP responses
func (*CacheHandler) RegisterHandler ¶
func (h *CacheHandler) RegisterHandler(version string, handler http.Handler)
RegisterHandler registers a handler for a specific version
type CacheInvalidator ¶
type CacheInvalidator struct {
// contains filtered or unexported fields
}
CacheInvalidator handles cache invalidation
func NewCacheInvalidator ¶
func NewCacheInvalidator(store CacheStore) *CacheInvalidator
NewCacheInvalidator creates a new cache invalidator
func (*CacheInvalidator) AddRule ¶
func (i *CacheInvalidator) AddRule(pattern string, tags []string) error
AddRule adds an invalidation rule
func (*CacheInvalidator) InvalidateByPattern ¶
func (i *CacheInvalidator) InvalidateByPattern(ctx context.Context, pattern string) error
InvalidateByPattern invalidates cache entries matching a pattern
func (*CacheInvalidator) InvalidateByTag ¶
func (i *CacheInvalidator) InvalidateByTag(ctx context.Context, tag string) error
InvalidateByTag invalidates all entries with a specific tag
func (*CacheInvalidator) InvalidateKey ¶
func (i *CacheInvalidator) InvalidateKey(ctx context.Context, key string) error
InvalidateKey invalidates a specific cache key
type CacheKeyGenerator ¶
type CacheKeyGenerator struct {
// contains filtered or unexported fields
}
CacheKeyGenerator generates cache keys based on request
func NewCacheKeyGenerator ¶
func NewCacheKeyGenerator() *CacheKeyGenerator
NewCacheKeyGenerator creates a new cache key generator
func (*CacheKeyGenerator) Generate ¶
func (g *CacheKeyGenerator) Generate(r *http.Request) string
Generate generates a cache key from a request
func (*CacheKeyGenerator) SetIncludeHeaders ¶
func (g *CacheKeyGenerator) SetIncludeHeaders(headers []string)
SetIncludeHeaders sets headers to include in cache key
func (*CacheKeyGenerator) SetIncludeQuery ¶
func (g *CacheKeyGenerator) SetIncludeQuery(include bool)
SetIncludeQuery includes query parameters in cache key
type CacheStats ¶
type CacheStats struct {
Hits int64
Misses int64
Evictions int64
Items int64
MemoryBytes int64
Uptime time.Duration
}
CacheStats contains cache statistics
type CacheStore ¶
type CacheStore interface {
// Get retrieves a cached value
Get(ctx context.Context, key string) (*Cache, error)
// Set stores a value in cache
Set(ctx context.Context, key string, cache *Cache) error
// Delete removes a value from cache
Delete(ctx context.Context, key string) error
// Exists checks if a key exists
Exists(ctx context.Context, key string) (bool, error)
// InvalidateByTag removes all entries with a specific tag
InvalidateByTag(ctx context.Context, tag string) error
// Clear removes all entries
Clear(ctx context.Context) error
// Stats returns cache statistics
Stats(ctx context.Context) (CacheStats, error)
}
CacheStore defines the interface for cache storage backends
type CacheWarmer ¶
type CacheWarmer struct {
// contains filtered or unexported fields
}
CacheWarmer pre-warms the cache with common requests
func NewCacheWarmer ¶
func NewCacheWarmer(store CacheStore) *CacheWarmer
NewCacheWarmer creates a new cache warmer
func (*CacheWarmer) AddPrefetch ¶
func (w *CacheWarmer) AddPrefetch(req PrefetchRequest)
AddPrefetch adds a request to prefetch
type ContentAnalysisStats ¶
type ContentAnalysisStats struct {
TotalAnalyzed int64 `json:"total_analyzed"`
ViolationsFound int64 `json:"violations_found"`
ByType map[string]int64 `json:"by_type"`
}
ContentAnalysisStats holds content analysis stats
type ETagger ¶
type ETagger struct {
// contains filtered or unexported fields
}
ETagger generates ETags for responses
func (*ETagger) GenerateForFile ¶
GenerateForFile generates an ETag for a file
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
InMemoryCache is an in-memory cache implementation
func NewInMemoryCache ¶
func NewInMemoryCache(maxItems int, maxMemory int64) *InMemoryCache
NewInMemoryCache creates a new in-memory cache
func (*InMemoryCache) Clear ¶
func (c *InMemoryCache) Clear(ctx context.Context) error
Clear removes all entries
func (*InMemoryCache) Delete ¶
func (c *InMemoryCache) Delete(ctx context.Context, key string) error
Delete removes a value from cache
func (*InMemoryCache) InvalidateByTag ¶
func (c *InMemoryCache) InvalidateByTag(ctx context.Context, tag string) error
InvalidateByTag removes all entries with a specific tag
func (*InMemoryCache) Stats ¶
func (c *InMemoryCache) Stats(ctx context.Context) (CacheStats, error)
Stats returns cache statistics
type InvalidationRule ¶
InvalidationRule defines rules for cache invalidation
type JSONCacheValue ¶
type JSONCacheValue struct {
Data interface{} `json:"data"`
ETag string `json:"etag"`
ExpiresAt time.Time `json:"expires_at"`
}
JSONCacheValue is a cache value for JSON responses
func NewJSONCacheValue ¶
func NewJSONCacheValue(data interface{}, ttl time.Duration) *JSONCacheValue
NewJSONCacheValue creates a new JSON cache value
func (*JSONCacheValue) IsExpired ¶
func (j *JSONCacheValue) IsExpired() bool
IsExpired returns true if the cache value is expired
func (*JSONCacheValue) MarshalBinary ¶
func (j *JSONCacheValue) MarshalBinary() ([]byte, error)
MarshalBinary marshals to binary
func (*JSONCacheValue) UnmarshalBinary ¶
func (j *JSONCacheValue) UnmarshalBinary(data []byte) error
UnmarshalBinary unmarshals from binary
type LastModifiedHandler ¶
type LastModifiedHandler struct {
// contains filtered or unexported fields
}
LastModifiedHandler handles Last-Modified conditional requests
func NewLastModifiedHandler ¶
func NewLastModifiedHandler() *LastModifiedHandler
NewLastModifiedHandler creates a new Last-Modified handler
func (*LastModifiedHandler) Handle ¶
func (h *LastModifiedHandler) Handle(next http.Handler) http.Handler
Handle processes If-Modified-Since and If-Unmodified-Since
func (*LastModifiedHandler) SetLastModified ¶
func (h *LastModifiedHandler) SetLastModified(w http.ResponseWriter, t time.Time)
SetLastModified sets Last-Modified header
type MLStatsHandler ¶
type MLStatsHandler struct {
// contains filtered or unexported fields
}
MLStatsHandler handles ML anomaly detection statistics API requests
func NewMLStatsHandler ¶
func NewMLStatsHandler(p *proxy.ProxyWithML) *MLStatsHandler
NewMLStatsHandler creates a new ML stats handler
func (*MLStatsHandler) HandleGetStats ¶
func (h *MLStatsHandler) HandleGetStats(w http.ResponseWriter, r *http.Request)
HandleGetStats handles GET /api/v1/ml/stats
func (*MLStatsHandler) HandleHealth ¶
func (h *MLStatsHandler) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth handles GET /api/v1/ml/health
func (*MLStatsHandler) HandleResetStats ¶
func (h *MLStatsHandler) HandleResetStats(w http.ResponseWriter, r *http.Request)
HandleResetStats handles POST /api/v1/ml/stats/reset
func (*MLStatsHandler) HandleUpdateConfig ¶
func (h *MLStatsHandler) HandleUpdateConfig(w http.ResponseWriter, r *http.Request)
HandleUpdateConfig handles PUT /api/v1/ml/config
func (*MLStatsHandler) RegisterRoutes ¶
func (h *MLStatsHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers ML stats API routes
type MLStatsResponse ¶
type MLStatsResponse struct {
Middleware *MiddlewareStats `json:"middleware,omitempty"`
PromptInjection *PromptInjectionStats `json:"prompt_injection,omitempty"`
ContentAnalysis *ContentAnalysisStats `json:"content_analysis,omitempty"`
BehavioralAnalysis *BehavioralAnalysisStats `json:"behavioral_analysis,omitempty"`
Sensitivity string `json:"sensitivity"`
Enabled bool `json:"enabled"`
RecentAnomalies []AnomalySummary `json:"recent_anomalies"`
}
MLStatsResponse represents the ML statistics API response
type MiddlewareStats ¶
type MiddlewareStats struct {
TotalRequests int64 `json:"total_requests"`
AnalyzedRequests int64 `json:"analyzed_requests"`
BlockedRequests int64 `json:"blocked_requests"`
AnomalyCounts map[string]int64 `json:"anomaly_counts"`
LastUpdate time.Time `json:"last_update"`
}
MiddlewareStats holds middleware statistics
type NegotiationResult ¶
type NegotiationResult struct {
Version string
VersionInfo *Version
ContentType string // e.g., "application/vnd.aegisgate.v1+json"
DeprecationInfo string
}
NegotiationResult contains the result of version negotiation
type PrefetchRequest ¶
PrefetchRequest defines a request to prefetch
type PromptInjectionStats ¶
type PromptInjectionStats struct {
TotalScanned int64 `json:"total_scanned"`
ThreatsDetected int64 `json:"threats_detected"`
BlockedCount int64 `json:"blocked_count"`
Sensitivity int `json:"sensitivity"`
ByPattern map[string]int64 `json:"by_pattern"`
}
PromptInjectionStats holds prompt injection detection stats
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main API server
func (*Server) AddRouteFunc ¶
func (s *Server) AddRouteFunc(version, method, path string, fn func(http.ResponseWriter, *http.Request))
AddRouteFunc adds a route with a handler function
func (*Server) Router ¶
func (s *Server) Router() *VersionedRouter
Router returns the underlying router
type ServerConfig ¶
type ServerConfig struct {
Host string
Port int
TLSEnabled bool
TLSCertFile string
TLSKeyFile string
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int
ShutdownTimeout time.Duration
// Feature flags
EnableVersioning bool
EnableCaching bool
EnableMetrics bool
EnableGraphQL bool
EnableHealth bool
// Versioning config
VersionConfig *VersionConfig
// Cache config
CacheConfig *CacheConfig
// Optional interfaces (using any to avoid import issues)
MetricsMgr interface {
ServeHTTP(http.ResponseWriter, *http.Request)
}
ProxySrv interface {
Start() error
Stop()
}
}
ServerConfig contains server configuration
func DefaultServerConfig ¶
func DefaultServerConfig() *ServerConfig
DefaultServerConfig returns default server configuration
type TenantAPIHandler ¶
type TenantAPIHandler struct {
// contains filtered or unexported fields
}
TenantAPIHandler handles tenant management API requests
func NewTenantAPIHandler ¶
func NewTenantAPIHandler(manager *tenant.Manager, storagePath string) *TenantAPIHandler
NewTenantAPIHandler creates a new tenant API handler
func (*TenantAPIHandler) ActivateTenant ¶
func (h *TenantAPIHandler) ActivateTenant(w http.ResponseWriter, r *http.Request)
ActivateTenant activates a tenant
func (*TenantAPIHandler) CreateTenant ¶
func (h *TenantAPIHandler) CreateTenant(w http.ResponseWriter, r *http.Request)
CreateTenant creates a new tenant
func (*TenantAPIHandler) DeleteTenant ¶
func (h *TenantAPIHandler) DeleteTenant(w http.ResponseWriter, r *http.Request)
DeleteTenant deletes a tenant
func (*TenantAPIHandler) ExportTenantAuditLog ¶
func (h *TenantAPIHandler) ExportTenantAuditLog(w http.ResponseWriter, r *http.Request)
ExportTenantAuditLog exports tenant audit logs
func (*TenantAPIHandler) GetTenant ¶
func (h *TenantAPIHandler) GetTenant(w http.ResponseWriter, r *http.Request)
GetTenant gets a tenant by ID
func (*TenantAPIHandler) GetTenantAuditLog ¶
func (h *TenantAPIHandler) GetTenantAuditLog(w http.ResponseWriter, r *http.Request)
GetTenantAuditLog gets tenant audit logs
func (*TenantAPIHandler) GetTenantCompliance ¶
func (h *TenantAPIHandler) GetTenantCompliance(w http.ResponseWriter, r *http.Request)
GetTenantCompliance gets tenant compliance settings
func (*TenantAPIHandler) GetTenantQuota ¶
func (h *TenantAPIHandler) GetTenantQuota(w http.ResponseWriter, r *http.Request)
GetTenantQuota gets tenant quota
func (*TenantAPIHandler) ListTenants ¶
func (h *TenantAPIHandler) ListTenants(w http.ResponseWriter, r *http.Request)
ListTenants lists all tenants
func (*TenantAPIHandler) RegisterRoutes ¶
func (h *TenantAPIHandler) RegisterRoutes(mux *http.ServeMux)
RegisterRoutes registers tenant management routes
func (*TenantAPIHandler) SuspendTenant ¶
func (h *TenantAPIHandler) SuspendTenant(w http.ResponseWriter, r *http.Request)
SuspendTenant suspends a tenant
func (*TenantAPIHandler) UpdateTenant ¶
func (h *TenantAPIHandler) UpdateTenant(w http.ResponseWriter, r *http.Request)
UpdateTenant updates a tenant
func (*TenantAPIHandler) UpdateTenantCompliance ¶
func (h *TenantAPIHandler) UpdateTenantCompliance(w http.ResponseWriter, r *http.Request)
UpdateTenantCompliance updates tenant compliance settings
func (*TenantAPIHandler) UpdateTenantQuota ¶
func (h *TenantAPIHandler) UpdateTenantQuota(w http.ResponseWriter, r *http.Request)
UpdateTenantQuota updates tenant quota
type VaryCacheKeyGenerator ¶
type VaryCacheKeyGenerator struct {
// contains filtered or unexported fields
}
VaryCacheKeyGenerator generates cache keys with Vary headers
func NewVaryCacheKeyGenerator ¶
func NewVaryCacheKeyGenerator() *VaryCacheKeyGenerator
NewVaryCacheKeyGenerator creates a Vary-aware key generator
type Version ¶
type Version struct {
Major int
Minor int
Label string // e.g., "beta", "alpha", "rc1"
Deprecated bool // Version is deprecated
Sunset *time.Time // When version will be removed
Unsupported bool // Version is no longer supported
}
Version represents an API version
func ParseVersion ¶
ParseVersion parses a version string
func (*Version) Compare ¶
Compare compares two versions Returns: -1 if v < other, 0 if v == other, 1 if v > other
func (*Version) IsDeprecated ¶
IsDeprecated returns true if version is deprecated but still supported
func (*Version) IsSupported ¶
IsSupported returns true if version is supported
type VersionConfig ¶
type VersionConfig struct {
Enable bool
StrictMode bool
Negotiator string // "header", "query", "path", "content-type"
DefaultVersion string
}
VersionConfig contains versioning configuration
type VersionHandler ¶
type VersionHandler struct {
// contains filtered or unexported fields
}
VersionHandler routes requests to version-specific handlers
func NewVersionHandler ¶
func NewVersionHandler(manager *VersionManager) *VersionHandler
NewVersionHandler creates a new version handler router
func (*VersionHandler) RegisterHandler ¶
func (vh *VersionHandler) RegisterHandler(version string, handler http.Handler)
RegisterHandler registers a handler for a specific version
func (*VersionHandler) ServeHTTP ¶
func (vh *VersionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes to the appropriate version handler
func (*VersionHandler) SetNotFound ¶
func (vh *VersionHandler) SetNotFound(handler http.Handler)
SetNotFound sets the handler for unmatched versions
type VersionList ¶
type VersionList []string
VersionList is a list of version strings
func (VersionList) Sort ¶
func (v VersionList) Sort() []string
Sort returns the sorted list of version strings. Sort returns the sorted list of version strings.
type VersionManager ¶
type VersionManager struct {
// contains filtered or unexported fields
}
VersionManager manages API versions
func DefaultVersionManager ¶
func DefaultVersionManager() *VersionManager
DefaultVersionManager creates a default version manager with standard versions
func NewVersionManager ¶
func NewVersionManager() *VersionManager
NewVersionManager creates a new version manager
func (*VersionManager) GetDefaultVersion ¶
func (m *VersionManager) GetDefaultVersion() string
GetDefaultVersion returns the default version
func (*VersionManager) GetDeprecationWarning ¶
func (m *VersionManager) GetDeprecationWarning(version string) (string, bool)
GetDeprecationWarning returns deprecation info if version is deprecated
func (*VersionManager) GetSupportedVersions ¶
func (m *VersionManager) GetSupportedVersions() []string
GetSupportedVersions returns all supported versions
func (*VersionManager) GetVersion ¶
func (m *VersionManager) GetVersion(version string) (*Version, bool)
GetVersion returns version info
func (*VersionManager) RegisterDeprecated ¶
func (m *VersionManager) RegisterDeprecated(deprecated, replacement string, sunset time.Time)
RegisterDeprecated marks a version as deprecated
func (*VersionManager) RegisterUnsupported ¶
func (m *VersionManager) RegisterUnsupported(version string)
RegisterUnsupported marks a version as unsupported
func (*VersionManager) RegisterVersion ¶
func (m *VersionManager) RegisterVersion(v *Version)
RegisterVersion registers an API version
func (*VersionManager) SetDefaultVersion ¶
func (m *VersionManager) SetDefaultVersion(version string)
SetDefaultVersion sets the default version
type VersionNegotiator ¶
type VersionNegotiator struct {
// contains filtered or unexported fields
}
VersionNegotiator handles API version negotiation
func NewVersionNegotiator ¶
func NewVersionNegotiator(manager *VersionManager) *VersionNegotiator
NewVersionNegotiator creates a new version negotiator
func (*VersionNegotiator) Negotiate ¶
func (n *VersionNegotiator) Negotiate(r *http.Request) *NegotiationResult
Negotiate determines the best version from a request
type VersionedRouter ¶
type VersionedRouter struct {
// contains filtered or unexported fields
}
VersionedRouter is a router that supports versioned routes
func NewVersionedRouter ¶
func NewVersionedRouter(manager *VersionManager) *VersionedRouter
NewVersionedRouter creates a new versioned router
func (*VersionedRouter) AddRoute ¶
func (vr *VersionedRouter) AddRoute(version, method, path string, handler http.Handler)
AddRoute adds a route for a specific version
func (*VersionedRouter) Handler ¶
func (vr *VersionedRouter) Handler() http.Handler
Handler returns a handler for the router