Expand description
What a page type serves on its public URL, and how Accept picks.
Most page types render a Tera template. Some — feeds a CRM consumes,
endpoints that only ever answer machines — have no template at all
and exist purely to return JSON. Before this module that was
unsayable: crate::page_type::PageTypeHandler::default_template
is a required &'static str, and render_inner hands whatever it
finds straight to Tera, so a blank template is a 500.
Two enums, deliberately distinct:
PageViewModeis what the operator declares and what thecms_page_type.view_modecolumn stores.Autois the default and means “work it out from the template”.PageViewKindis whatresolve_kinddecides, and it is the only thing the renderer branches on.
§Auto never opens a JSON view on a page that has a template
It would be tempting to make Auto mean “negotiate on everything”.
That would silently publish a JSON representation of every page’s
extension + builder values on every existing site the moment
this ships — including hosts that deliberately never mounted
crate::api::router. So Auto + a template is HTML-only and
ignores Accept entirely. Since every existing cms_page_type row
has a non-empty default_template, the upgrade is a no-op. Serving
JSON from a page that also renders HTML is opt-in via
PageViewMode::Api.
Enums§
- Accept
- The coarse media-type preference distilled from an
Acceptheader. - Page
View Kind - What a page type can actually serve, once the declared mode and the template have been reconciled. This is what the renderer branches on.
- Page
View Mode - The declared mode, stored in
cms_page_type.view_mode.
Functions§
- kind_
for resolve_kindover a loaded registry row.- parse_
accept - Parse an
Acceptheader into a coarse preference. - resolve_
kind - Reconcile a declared mode with the template actually on the row.