Documentation
¶
Overview ¶
Package server — Content-Security-Policy construction.
The CSP is computed once at startup from the embedded HTML entrypoints rather than hardcoded, so the two inline <head> scripts — the <script type="importmap"> block and the anti-FOUC <script data-theme-init> IIFE (@cplieger/ui-primitives' themeInitSnippet output) — are each allowed by an exact sha256 hash. Under default-src 'self' an inline script has no exception, so without a matching script-src hash the browser blocks it: blocking the import map makes every bare-specifier import (@cplieger/actions, @cplieger/reactive) fail to resolve so the page never boots (breaking the login / first-boot wizard), and blocking the theme-init script flashes the wrong theme before the stylesheets load. Deriving each hash from the embedded file means an edit (even a whitespace-only reformat) needs no hand-updated constant.
Package server provides the HTTP server and history poller for subtitle management.
The package is split across several files by concern:
- server.go — New() constructor and lifecycle (this file)
- server_types.go — Server struct, embedded dep groups, Option functions
- server_init.go — initHandlers (handler family construction)
- middleware.go — requireAuth / requireRole / requireConfigured
- routes.go — routeGroup + registerRoutes + permission model
- poller.go — Sonarr/Radarr history polling + import processing
- scheduler.go — full-scan pipeline + DB maintenance + auth cleanup
- *_handlers.go — per-concern HTTP handler families
Index ¶
- func SecretKeyNames() []string
- type Metrics
- type Option
- func WithArrClientFactories(newSonarr func(baseURL, apiKey string) (api.SonarrClient, error), ...) Option
- func WithConfig(cfg api.ConfigProvider, sonarr api.SonarrClient, radarr api.RadarrClient) Option
- func WithConfigLoader(l api.ConfigLoader) Option
- func WithDefaultConfig(cfg []byte) Option
- func WithMetrics(m Metrics) Option
- func WithPort(port int) Option
- func WithSchema(f api.SchemaFunc) Option
- func WithSubtitleProc(p api.SubtitleProcessor) Option
- func WithWire(w wiring.Func) Option
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SecretKeyNames ¶
func SecretKeyNames() []string
SecretKeyNames returns the list of YAML keys treated as secrets. Delegates to confighandlers.SecretKeyNames.
Types ¶
type Metrics ¶
type Metrics interface {
RecordSearch(provider api.ProviderID, dur time.Duration, err error)
RecordDownload(provider api.ProviderID, err error)
AdaptiveSkip()
RecordScan(items, found int, dur time.Duration)
RecordImport(source api.PollKey)
RecordHTTP(method, path string, status int, d time.Duration)
RecordPanic()
TotalSearches() int64
Handler() http.HandlerFunc
// Store observability (Requirement 17).
RecordStoreFileSize(bytes int64)
RecordStoreFreelistBytes(bytes int64)
RecordReconcile(deleted int, reset int64, dur time.Duration)
RecordBackupSuccess(dur time.Duration)
// Mode observability: 1 when a valid configuration is active, 0 unconfigured.
SetConfigured(ok bool)
}
Metrics is the observability interface consumed by the server package.
type Option ¶
type Option func(*Server)
Option configures a Server during construction.
func WithArrClientFactories ¶ added in v0.1.106
func WithArrClientFactories( newSonarr func(baseURL, apiKey string) (api.SonarrClient, error), newRadarr func(baseURL, apiKey string) (api.RadarrClient, error), ) Option
WithArrClientFactories sets the factories for creating Sonarr and Radarr API clients, used by hot reload and config-save connectivity checks.
func WithConfig ¶
func WithConfig(cfg api.ConfigProvider, sonarr api.SonarrClient, radarr api.RadarrClient) Option
WithConfig sets the initial configuration and arr clients.
func WithConfigLoader ¶
func WithConfigLoader(l api.ConfigLoader) Option
WithConfigLoader sets the config loader.
func WithDefaultConfig ¶
WithDefaultConfig sets the embedded default config bytes.
func WithSchema ¶
func WithSchema(f api.SchemaFunc) Option
WithSchema sets the config schema function.
func WithSubtitleProc ¶
func WithSubtitleProc(p api.SubtitleProcessor) Option
WithSubtitleProc sets the subtitle processor.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main application server.
func (*Server) SetAuth ¶
func (s *Server) SetAuth(store authstore.AuthStore, rl ratelimit.Checker, wa *webauthn.WebAuthn, oidc *authoidc.Provider)
SetAuth configures authentication dependencies on the server.
func (*Server) SetOIDCLazy ¶
func (s *Server) SetOIDCLazy(cfg auth.OIDCConfig)
SetOIDCLazy stores the OIDC config for lazy provider initialization.
func (*Server) StartUnconfigured ¶
StartUnconfigured starts the HTTP server without a valid config.
Source Files
¶
- activity.go
- admin_bootstrap.go
- backup.go
- config_handlers.go
- config_secrets.go
- coverage_count.go
- events.go
- handler_delegates.go
- helpers.go
- lifecycle.go
- manual.go
- manual_download.go
- middleware.go
- poller.go
- poster_client.go
- query_handlers.go
- reload.go
- routes.go
- scan_handlers.go
- scheduler.go
- scheduler_scan.go
- security.go
- server.go
- server_init.go
- server_types.go
- session_batcher.go
- storemetrics.go
- sync_handlers.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package activity provides concurrent-safe activity and alert tracking for the subflux UI status indicator.
|
Package activity provides concurrent-safe activity and alert tracking for the subflux UI status indicator. |
|
Package authhandlers provides shared types and utilities for the server's authentication handler cluster: login, WebAuthn, OIDC, admin user management, and security management (password change, API keys, passkeys).
|
Package authhandlers provides shared types and utilities for the server's authentication handler cluster: login, WebAuthn, OIDC, admin user management, and security management (password change, API keys, passkeys). |
|
Package confighandlers provides HTTP handlers for configuration CRUD operations: get, save, reset, schema, and path validation.
|
Package confighandlers provides HTTP handlers for configuration CRUD operations: get, save, reset, schema, and path validation. |
|
Package coverage provides pure computation functions for subtitle coverage analysis.
|
Package coverage provides pure computation functions for subtitle coverage analysis. |
|
Package coveragehandlers provides HTTP handlers for the /api/coverage/* endpoints.
|
Package coveragehandlers provides HTTP handlers for the /api/coverage/* endpoints. |
|
Package events is subflux's typed server-sent-events layer: the sealed Event/EventData types the app publishes, marshaled onto the shared webhttp/sse broadcast hub.
|
Package events is subflux's typed server-sent-events layer: the sealed Event/EventData types the app publishes, marshaled onto the shared webhttp/sse broadcast hub. |
|
Package filehandlers provides HTTP handlers for the /api/files/* endpoints.
|
Package filehandlers provides HTTP handlers for the /api/files/* endpoints. |
|
Package httphelpers provides shared HTTP handler prelude helpers used across server sub-packages.
|
Package httphelpers provides shared HTTP handler prelude helpers used across server sub-packages. |
|
Package manualops implements the business logic for manual subtitle search and download operations.
|
Package manualops implements the business logic for manual subtitle search and download operations. |
|
Package mediahandlers provides HTTP handlers for the /api/media/* endpoints.
|
Package mediahandlers provides HTTP handlers for the /api/media/* endpoints. |
|
Package polling provides the history-polling subsystem for Sonarr/Radarr import events and the write-through poll timestamp cache.
|
Package polling provides the history-polling subsystem for Sonarr/Radarr import events and the write-through poll timestamp cache. |
|
Package previewhandlers provides HTTP handlers for the video/subtitle preview and poster proxy endpoints.
|
Package previewhandlers provides HTTP handlers for the video/subtitle preview and poster proxy endpoints. |
|
Package queryhandlers provides read-only HTTP query handlers: subtitle state, backoff, manual locks, providers, parsed config, score simulation, and dashboard stats.
|
Package queryhandlers provides read-only HTTP query handlers: subtitle state, backoff, manual locks, providers, parsed config, score simulation, and dashboard stats. |
|
Package scanning implements the full-scan orchestration engine.
|
Package scanning implements the full-scan orchestration engine. |
|
Package scheduler provides the periodic full-scan pipeline, DB maintenance, and auth cleanup scheduling for the subflux server.
|
Package scheduler provides the periodic full-scan pipeline, DB maintenance, and auth cleanup scheduling for the subflux server. |
|
Package serveradapter provides adapter types that bridge the server's activity, alert, and event subsystems to the interfaces consumed by the scanning and manualops packages.
|
Package serveradapter provides adapter types that bridge the server's activity, alert, and event subsystems to the interfaces consumed by the scanning and manualops packages. |
|
Package sessionbatch implements batched session activity updates to reduce SQLite write-lock acquisitions.
|
Package sessionbatch implements batched session activity updates to reduce SQLite write-lock acquisitions. |
|
Package showskip provides a TTL-based cache for show-level subtitle pre-check results.
|
Package showskip provides a TTL-based cache for show-level subtitle pre-check results. |
|
Package synchandlers provides HTTP handlers for subtitle sync operations (audio-based sync and manual offset adjustment).
|
Package synchandlers provides HTTP handlers for subtitle sync operations (audio-based sync and manual offset adjustment). |