Documentation
¶
Index ¶
- Variables
- func AllowedFormats(formats []string) []string
- func ExportRequests(data []*StoredRequest, format string) ([]byte, string, string, error)
- func StreamExport(w io.Writer, iter RequestIterator, format string) (string, string, error)
- type AuthManager
- type ListOptions
- type RequestIterator
- type Service
- type Session
- type StoredRequest
- type WebsocketHub
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCredential = errors.New("invalid username or password")
ErrInvalidCredential indicates username/password mismatch.
Functions ¶
func AllowedFormats ¶
AllowedFormats normalizes configured export formats.
func ExportRequests ¶
ExportRequests serializes stored requests into the desired format.
func StreamExport ¶
StreamExport 以流式方式导出,避免大数据加载内存
Types ¶
type AuthManager ¶
type AuthManager struct {
// contains filtered or unexported fields
}
AuthManager performs credential validation and session management.
func NewAuthManager ¶
func NewAuthManager(cfg config.WebAuthConfig) *AuthManager
NewAuthManager creates a new AuthManager from configuration.
func (*AuthManager) Cleanup ¶
func (a *AuthManager) Cleanup()
Cleanup removes expired sessions; called periodically if needed.
func (*AuthManager) Enabled ¶
func (a *AuthManager) Enabled() bool
Enabled indicates whether authentication is active.
func (*AuthManager) Login ¶
func (a *AuthManager) Login(username, password string) (*Session, error)
Login validates credentials and returns a new session.
func (*AuthManager) Logout ¶
func (a *AuthManager) Logout(token string)
Logout removes a session token.
type ListOptions ¶
type ListOptions = storage.ListOptions
ListOptions 是 storage.ListOptions 的别名,兼容现有调用。
type RequestIterator ¶
type RequestIterator func(func(*StoredRequest) bool) error
RequestIterator 用于按需遍历请求
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service bundles web UI and API capabilities.
func NewService ¶
NewService builds a Service from configuration.
func (*Service) Record ¶
func (s *Service) Record(data *StoredRequest)
Record stores the request and pushes to websocket clients.
func (*Service) RegisterRoutes ¶
RegisterRoutes wires HTTP routes into the provided router.
type Session ¶
type Session struct {
ID string `json:"id"`
Username string `json:"username"`
Role string `json:"role"`
ExpiresAt time.Time `json:"expires_at"`
}
Session describes an authenticated user session.
type StoredRequest ¶
type StoredRequest = storage.StoredRequest
StoredRequest 是 storage.StoredRequest 的别名,方便 Web 模块复用。
type WebsocketHub ¶
type WebsocketHub struct {
// contains filtered or unexported fields
}
WebsocketHub manages live connections for request broadcasts.
func NewWebsocketHub ¶
func NewWebsocketHub(log logger.Logger) *WebsocketHub
NewWebsocketHub creates a new hub.
func (*WebsocketHub) Broadcast ¶
func (h *WebsocketHub) Broadcast(event interface{})
Broadcast sends payload to all active connections.
func (*WebsocketHub) Upgrade ¶
func (h *WebsocketHub) Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
Upgrade upgrades the HTTP connection to WebSocket.