Documentation
¶
Index ¶
- type Context
- func (ctx *Context) GetAge() time.Duration
- func (ctx *Context) GetCallCount() int64
- func (ctx *Context) GetHeader(key string) string
- func (ctx *Context) GetInfo() map[string]interface{}
- func (ctx *Context) GetTimeSinceLastAccess() time.Duration
- func (ctx *Context) IncrementCallCount()
- func (ctx *Context) IsExpired(expiration time.Duration) bool
- func (ctx *Context) SetHeader(key, value string)
- func (ctx *Context) UpdateLastAccessed()
- type Manager
- func (m *Manager) BlockSession(sessionID string)
- func (m *Manager) CheckRateLimit(sessionID string) bool
- func (m *Manager) Close() error
- func (m *Manager) CreateSession(headers map[string]string) *Context
- func (m *Manager) DeleteSession(sessionID string)
- func (m *Manager) GetActiveSessions() []map[string]interface{}
- func (m *Manager) GetOrCreateSession(sessionID string, headers map[string]string) *Context
- func (m *Manager) GetSession(sessionID string) (*Context, bool)
- func (m *Manager) GetSessionStats() map[string]interface{}
- func (m *Manager) IsSessionBlocked(sessionID string) bool
- func (m *Manager) UnblockSession(sessionID string)
- func (m *Manager) UpdateSession(sessionID string, ctx *Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
ID string `json:"id"`
Headers map[string]string `json:"headers"`
CreatedAt time.Time `json:"created_at"`
LastAccessed time.Time `json:"last_accessed"`
CallCount int64 `json:"call_count"`
UserAgent string `json:"user_agent"`
RemoteAddr string `json:"remote_addr"`
// Rate limiting
RequestCount int64 `json:"request_count"`
WindowStart time.Time `json:"window_start"`
// Security
IsBlocked bool `json:"is_blocked"`
// contains filtered or unexported fields
}
Context represents a session context
func (*Context) GetCallCount ¶
GetCallCount returns the call count
func (*Context) GetTimeSinceLastAccess ¶
GetTimeSinceLastAccess returns the time since last access
func (*Context) IncrementCallCount ¶
func (ctx *Context) IncrementCallCount()
IncrementCallCount increments the call count
func (*Context) UpdateLastAccessed ¶
func (ctx *Context) UpdateLastAccessed()
UpdateLastAccessed updates the last accessed time
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages user sessions
func NewManager ¶
NewManager creates a new session manager
func (*Manager) BlockSession ¶
BlockSession blocks a session
func (*Manager) CheckRateLimit ¶
CheckRateLimit checks if a session has exceeded the rate limit
func (*Manager) CreateSession ¶
CreateSession creates a new session
func (*Manager) DeleteSession ¶
DeleteSession removes a session
func (*Manager) GetActiveSessions ¶
GetActiveSessions returns information about active sessions
func (*Manager) GetOrCreateSession ¶
GetOrCreateSession gets an existing session or creates a new one
func (*Manager) GetSession ¶
GetSession retrieves a session by ID
func (*Manager) GetSessionStats ¶
GetSessionStats returns session statistics
func (*Manager) IsSessionBlocked ¶
IsSessionBlocked checks if a session is blocked
func (*Manager) UnblockSession ¶
UnblockSession unblocks a session
func (*Manager) UpdateSession ¶
UpdateSession updates an existing session