internal/server/README.md
Last Updated: March 4, 2026
internal/server wires Gin, middleware, and configuration into the PhotoPrism HTTP/HTTPS/WebDAV servers. It owns startup/shutdown orchestration, route registration, and helpers for recovery/logging. Subpackages (process, limits, etc.) are kept lightweight so CLI commands and workers can embed the same server behavior without duplicating boilerplate.
config.Config to decide TLS, AutoTLS, Unix sockets, proxies, compression, and trusted headers.Recovery() which logs stack traces and returns 500.Start) that configures listeners, middleware, and routes consistently.routes_webapp.go.start.go — main startup flow, listener selection (HTTP/HTTPS/AutoTLS/Unix socket), graceful shutdown.routes_webapp.go — Web UI routes and shared method helpers (MethodsGetHead).recovery.go — panic recovery middleware with stack trace logging.logger.go — request logging middleware (enabled in debug mode).security.go — security headers and trusted proxy/platform handling.webdav_*.go & tests — WebDAV handlers and regression tests for overwrite, traversal, and metadata flags.webdav_path.go — shared helper to classify built-in and path-proxied WebDAV routes.process/ — light wrappers for server process metadata.internal/api — registers REST endpoints consumed by registerRoutes.internal/config — supplies HTTP/TLS/socket settings, compression, proxies, and base URI paths.internal/server/process — exposes process ID for logging.pkg/http/header — shared HTTP header constants used by health endpoints.ReadHeaderTimeout is configured via PHOTOPRISM_HTTP_HEADER_TIMEOUT / --http-header-timeout (default 15s).MaxHeaderBytes is configured via PHOTOPRISM_HTTP_HEADER_BYTES / --http-header-bytes (default 1 MiB).IdleTimeout is configured via PHOTOPRISM_HTTP_IDLE_TIMEOUT / --http-idle-timeout (default 180s).ReadTimeout / WriteTimeout remain disabled to avoid breaking large transfers.Content-Security-Policy, X-Frame-Options) on /originals and /import paths.207 Multi-Status responses normalize XML media type to application/xml; charset=utf-8.autocert and spins up a redirect listener; ensure ports 80/443 are reachable.force query removes stale sockets; permissions can be set via mode query./livez, /health, /healthz, /readyz) return Cache-Control: no-store and Access-Control-Allow-Origin: *.golangci-lint run ./internal/server... and go test ./internal/server/...webdav_*_test.go; they rely on temp directories and in-memory routers, including PROPFIND 207 XML/header assertions and path classification checks.Start with context cancellation so graceful shutdown is triggered (server.Close()).registerRoutes and reuse MethodsGetHead for safe verbs.