Skip to content

Core Concepts

Headless routes incoming HTTP requests through HeadlessKernel, authenticates principals via pluggable AuthGuardInterface guards, and dispatches to namespace providers registered in ProviderRegistry.

flowchart TD
    A["HTTP Request (/api/v1/* or frontend path in Full Headless)"] --> B{"PassthroughMatcher matches?"}
    B -- Yes --> C["Pass through to native ProcessWire template / URL hook"]
    B -- No --> D["HeadlessKernel enforces CORS, 2 MiB JSON cap & RateLimiter"]
    D --> E["AuthGuardInterface chain (ApiKey / BearerJwt / Hmac / Session / Public)"]
    E --> F["ProviderRegistry dispatches namespace (pages / entries / resources / actions / auth / schema / sibling)"]
    F --> G["PageAccessPolicy + SelectorGuard + FieldTransformerInterface"]
    G --> H["HeadlessResponse JSON envelope (+ ETag / pagination meta)"]
  • Hybrid Mode (default): Your existing ProcessWire frontend templates render HTML normally, while Headless serves REST endpoints under apiPrefix (default /api/v1).
  • Full Headless Mode ($headless->doHeadless() or Settings -> Full Headless Mode): Intercepts non-admin frontend requests and resolves page paths to JSON automatically (resolvePaths: true), while bypassing patterns in PassthroughMatcher (defaults: ['/sitemap.xml', '/sitemap.xsl', '/robots.txt', '/humans.txt', '/llms.txt', '/sitemap-*', '/_react/*']).

Instead of reusing one master key everywhere, SecretVault::secretFor($purpose) derives isolated 32-byte HKDF-SHA256 subkeys (headless:jwt, headless:hmac, headless:preview, headless:hash) from the persistent secret stored in the headless singleton blueprint.

3. Providers, Resources, Actions & Transformers

Section titled “3. Providers, Resources, Actions & Transformers”
  • HeadlessProviderInterface: Owns a top-level URL namespace (built-in: pages, entries, resources, actions, auth, schema; plus sibling modules discovered lazily via headlessProviders).
  • ResourceBlueprint: Declaratively exposes a ProcessWire selector as a REST collection under /api/v1/resources/{name} with explicit fields, filterable, searchable, readAuth, writeAuth, computed, and cacheTtl.
  • HeadlessAction: Exposes a custom HTTP handler under /api/v1/actions/{path} with auth modes, scopes, and per-action rate limiting.
  • FieldTransformerInterface: Serializes ProcessWire fields cleanly via TransformationContext (depth, maxDepth, language, visited cycle guard). Ships with ScalarFieldTransformer, MediaFieldTransformer, PageReferenceTransformer, and EntriesFieldTransformer.

Next steps