Expand description
URL → Page resolution.
Two paths:
-
Materialized
url_pathshort-circuit. The request URL is normalized (strip trailing slash unless root) and looked up directly viaWHERE url_path = ?— one query regardless of tree depth. Theurl_pathcolumn is indexed and maintained bytree_opson every create / move / slug change. -
Slug-walk fallback for cases the materialized lookup misses — historical rows from before slice 1, draft-preview routes, etc. Walks the slug chain one level at a time and filters to the public statuses.
Both paths serve the public statuses — published and
archived (superseded-but-preserved content). Drafts,
scheduled, and expired (takedown) rows stay invisible to anonymous
visitors. The caller reads page.status to distinguish the two
served states.
Functions§
- canonical_
request_ path - Normalize a request path into the canonical form stored in
cms_page.url_path. Leading slash kept; trailing slash stripped for non-root URLs. Empty / missing path collapses to/. Exposed for the router’s cache-key builder. - resolve_
by_ url_ path - Look up the page matching
url_pathdirectly. One indexed SELECT. ReturnsOk(None)when the row is missing OR isn’t public (published / archived). The caller readspage.statusto tell the two apart. - resolve_
by_ walk - Walk the URL path one slug at a time. Used as a fallback when the
materialized
url_pathlookup misses (legacy rows, preview routes, etc.) and for the per-segment ancestry queries that rendered content depends on. - resolve_
path - Resolve a request URL to a
Page. Tries the materializedurl_pathfirst (one query); falls back to the slug walk when no row is found that way (legacy data, in-flight backfills, etc.). - resolve_
routable - When
resolve_pathmisses, walk ancestor prefixes ofrequest_pathlooking for aPagewhose registeredPageTypeHandler::routes()accepts the remaining suffix. Returns the matched page + match details on first hit (longest prefix wins becausecrate::routable::ancestor_prefixesorders from most-specific to root). - served_
statuses - Statuses a public page can have.
archivedjoinspublished;scheduledis included only so a page whose go-live time has passed is served before the sweep flips it —visible_nowdecides.expiredis excluded so takedown still 404s. OwnedStrings for theis_inbinds. - visible_
now - Whether a page is public at
now, judged by its dates rather than by whether the schedule sweep has run yet: a scheduled page goes live atgo_live_at, a published one comes down atexpire_at.