Skip to main content

Module url

Module url 

Source
Expand description

URLs into the request’s panel, so app code never spells a prefix.

Each helper answers for the panel serving the request: the one whose prefix the request is under, or the one it entered with PanelHandle::enter. A resource or page that panel does not register has no URL there, and the helper returns None. auth answers for the pages auth serves: sign-in, profile, two-factor and the rest of AuthPage.

Every helper but file also answers in a PanelHandle::context, so a job or a test spells no path: a page, a resource, an auth page or a record. A handle Panel::handle gives, which no router mounts, knows only its records’ URLs.

Each helper answers a path. An absolute URL, for a mail or a payment provider’s return, joins it to the router’s BaseUrl, which a handle’s context carries too: topcoat::context::try_base_url(cx)?.join(&path).

let posts = tablo_core::url::resource::<PostResource>(cx); // Some("/admin/posts")
let media = tablo_core::url::page::<MediaLibraryPage>(cx); // Some("/admin/media-library")
let home = tablo_core::url::panel(cx); // Some("/admin")

Enums§

AuthPage
A page or an endpoint auth serves on a panel, for auth.

Functions§

action
The route the action A runs on record at, e.g. /admin/posts/42/-/actions/publish, or None when R does not declare A on a record: on its rows, detail or edit page.
auth
The URL of page in the request’s panel, such as /admin/profile; None when the panel’s Auth does not serve it, as the other helpers answer for a resource the panel does not register.
bulk_action
The route the action A runs on a selection at, e.g. /admin/posts/-/actions/publish, which takes the selected keys in its ids field, or None when R does not declare A in its bulk bar.
create
R’s create page, e.g. /admin/posts/-/create, or None when R serves none.
delete
The route that deletes record, e.g. /admin/posts/42/delete, which takes confirm=1.
edit
record’s edit page, e.g. /admin/posts/42/edit, or None when R has no record form.
file
The URL to link or show a stored file at: path with a signature that expires, when it names a file under a Panel::uploads_dir of any panel on the router, and path itself otherwise.
page
P’s URL in the request’s panel: {prefix}/{slug}, or the prefix itself for the panel’s home page.
panel
The request’s panel prefix, e.g. /admin.
record
record’s detail page in the context’s panel, e.g. /admin/posts/42, or None when R declares no detail.
record_page
record’s record page P, e.g. /admin/orders/42/history, or None when R does not declare P. The URL answers 403 to a request the page’s access refuses.
resource
R’s list URL in the request’s panel, e.g. /admin/posts.