web

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves the web GUI and API endpoints.

func NewHandler

func NewHandler(dispatcher *sanitizer.Dispatcher, pool *worker.Pool, logger *slog.Logger, maxFileSize int64) *Handler

NewHandler creates a new web handler.

func (*Handler) GetStats

func (h *Handler) GetStats() StatsJSON

GetStats returns the current stats (for use by metrics, gRPC health, etc.)

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers all HTTP routes on the given mux.

func (*Handler) Stop

func (h *Handler) Stop()

Stop signals the handler to stop its background cleanup goroutine. It is safe to call multiple times.

type SanitizeResponseJSON

type SanitizeResponseJSON struct {
	Status        string       `json:"status"`
	OriginalType  string       `json:"original_type"`
	OriginalSize  int64        `json:"original_size"`
	SanitizedSize int64        `json:"sanitized_size"`
	Threats       []ThreatJSON `json:"threats"`
	ErrorMessage  string       `json:"error_message,omitempty"`
	DownloadID    string       `json:"download_id,omitempty"`
	DurationMs    int64        `json:"duration_ms"`
}

SanitizeResponseJSON is the JSON response for a sanitization request.

type Stats

type Stats struct {
	FilesProcessed   atomic.Int64
	ThreatsRemoved   atomic.Int64
	FilesSanitized   atomic.Int64
	FilesClean       atomic.Int64
	FilesBlocked     atomic.Int64
	FilesErrored     atomic.Int64
	FilesUnsupported atomic.Int64
}

Stats tracks cumulative sanitization statistics for the dashboard.

func (*Stats) Snapshot

func (s *Stats) Snapshot() StatsJSON

type StatsJSON

type StatsJSON struct {
	FilesProcessed   int64 `json:"files_processed"`
	ThreatsRemoved   int64 `json:"threats_removed"`
	FilesSanitized   int64 `json:"files_sanitized"`
	FilesClean       int64 `json:"files_clean"`
	FilesBlocked     int64 `json:"files_blocked"`
	FilesErrored     int64 `json:"files_errored"`
	FilesUnsupported int64 `json:"files_unsupported"`
}

StatsJSON is the JSON-serializable snapshot of Stats.

type ThreatJSON

type ThreatJSON struct {
	Type        string `json:"type"`
	Location    string `json:"location"`
	Description string `json:"description"`
	Severity    string `json:"severity"`
}

ThreatJSON is the JSON representation of a detected threat.

Jump to

Keyboard shortcuts

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