How tarampampam/error-pages works
Project type and purpose
• This is a single‐binary Go application that serves two purposes:
a) a CLI tool (commands: serve, build, healthcheck, perftest)
b) an ultra‐lightweight HTTP server that dynamically renders and caches error pages in multiple formats.
• It bundles a set of Go‐template HTML “themes,” supports localization (l10n), in‐memory caching, on‐the‐fly minification, JSON/XML/plaintext responses, health checks, and integrates easily into Docker/K8s/Traefik/Ingress setups.
File structure
• cmd/error-pages/main.go
→ entrypoint for the CLI
• internal/cli/…
→ command definitions (serve, build, healthcheck, perftest, update_readme)
• internal/config/…
→ parsing flags+env, rotation modes, code definitions, template lists
• internal/logger/…
→ structured JSON logger abstraction
• internal/http/…
→ HTTP server: server.go, middleware (logreq), handlers (error_page, static, live, version), httptest helpers
• internal/template/…
→ Go‐template renderer + HTML/CSS/JS minification + properties injection
• l10n/…
→ JavaScript localization logic, translation files
• templates/…
→ embedded HTML themes (app-down, cats, connection, etc.)
• Dockerfile, Makefile, GitHub Actions, and .github/ CI/CD files
→ build, test, release pipelines, container packaging
README for additional insights
• Confirms a “serve” mode for live HTTP error page serving and a “build” mode for static page generation
• Describes CLI flags for templating, rotation, logging, formats, headers, K8s/Ing-Nginx/Traefik usage
• Emphasizes minimal resource usage, distroless Docker image, unprivileged user
Essential architectural elements to capture
• Separation of modes: serve vs. build
• Config → logger → HTTP server startup
• Middleware → handler → template engine → themes + localization
• Static‐build path using the same template engine
• Docker image build embedding all assets
• Integration hooks for Traefik/Ingress/K8s