web

package
v0.0.0-...-2a28936 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredential = errors.New("invalid username or password")

ErrInvalidCredential indicates username/password mismatch.

Functions

func AllowedFormats

func AllowedFormats(formats []string) []string

AllowedFormats normalizes configured export formats.

func ExportRequests

func ExportRequests(data []*StoredRequest, format string) ([]byte, string, string, error)

ExportRequests serializes stored requests into the desired format.

func StreamExport

func StreamExport(w io.Writer, iter RequestIterator, format string) (string, string, error)

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.

func (*AuthManager) Validate

func (a *AuthManager) Validate(token string) (*Session, error)

Validate finds a session by token and ensures it's not expired.

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

func NewService(cfg *config.WebConfig, store storage.Store, log logger.Logger) *Service

NewService builds a Service from configuration.

func (*Service) Close

func (s *Service) Close()

Close releases resources.

func (*Service) Record

func (s *Service) Record(data *StoredRequest)

Record stores the request and pushes to websocket clients.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(router *mux.Router)

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) Close

func (h *WebsocketHub) Close()

Close terminates all connections.

func (*WebsocketHub) Upgrade

Upgrade upgrades the HTTP connection to WebSocket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL