How try-veil/veil works
Project type and purpose
• Veil is an open‑source Caddy module (plugin) written in Go.
• Its purpose is to provide API management capabilities—subscription‑based access control, header validation, usage tracking, and dynamic onboarding of upstream APIs—within a Caddy server.
File structure
• packages/caddy: The core module implementation (Go code, handlers, models, store layer).
• configs / scripts / Makefile / Dockerfile / Caddyfile: Build, configuration, and deployment assets.
• tests/e2e and tests/upstream: End‑to‑end tests and a mock upstream service for integration testing.
• docs and docs/src: Docusaurus site for user and API documentation (Swagger, blogs, contribution guides).
• .github/workflows, goreleaser.yaml: CI/CD pipelines for build, test, docs‑deploy, Docker publish, and GitHub releases.
README for additional insights
• Core features: subscription access control, header validation, usage analytics, dynamic onboarding.
• Storage: SQLite (db_path).
• Build prerequisites: Go, xcaddy, CGO (to compile with SQLite).
• Configuration via Caddyfile.
Main components
a. Build & CI/CD
• Source code repository (GitHub)
• GitHub Actions workflows (lint, test, build, release, docs deploy)
• goreleaser → Docker images + GitHub releases
b. Runtime environment
• Caddy Server core
• Veil module (middleware layer)
• SQLite database (storage layer)
• Upstream APIs (onboarded external services)
c. Clients & Consumers
• API consumers (clients calling protected endpoints)
• API providers (register onboarded upstream)
d. Documentation site
• Docusaurus frontend (hosted via GitHub Pages)
• Swagger / MDX content
Relationships and data flows
• At build time: xcaddy + Go → compile Caddy + Veil plug‑in → Docker image.
• At deployment: Docker container runs Caddy with Veil loaded, Caddyfile points to Veil middleware on port 2020.
• Request flow at runtime:
1. Client → HTTP request → Caddy listener
2. Veil middleware intercepts →
• Validate subscription and headers (reads/writes SQLite store)
• Log usage metrics (writes SQLite)
• If valid → proxy request to configured upstream API
3. Upstream API response → Veil → Caddy → Client
• Admin/Provider flow:
• Provider calls Veil’s admin endpoints (Onboard, Update, Validate, Delete) → Veil handlers → update SQLite.
Architectural patterns and design principles
• Modular plugin architecture (Caddy modules)
• Middleware pattern for HTTP request interception
• Repository/Store abstraction for DB operations
• Single binary deployment (Caddy + modules)
• Test harness: embedded mock upstream for E2E tests
Technologies and frameworks
• Go and CGO (SQLite)
• Caddy and xcaddy plugin system
• SQLite for durable store
• Docker for containerization
• GitHub Actions for CI/CD
• Docusaurus + MDX + Swagger for docs