Route and Link
Route<P, Q> is a page served at a path, with path parameters P and search parameters Q. Link<S> is a link to that page.
Route
Declare one in routes! with its handler, and use the same value in the links to the page.
| Item | Summary |
|---|---|
routes! | Declares the pages of an application and the function that serves them. |
link | A link to this page, which has no parameters. |
link_with | A link to this page with the arguments args. |
url | The URL of this page with the arguments args, written on the server. |
path | The path as axum matches it, with each parameter still written {name}. |
Base | The path prefix an application is served under, such as /app behind a proxy. |
Base::new | The prefix path, which starts with / and does not end with one. |
Base::ROOT | No prefix: the application is served at the root of its host. |
Base::as_str | The prefix as text, empty for Base::ROOT. |
Parameters and links
| Item | Summary |
|---|---|
Params | The parameters of a Route: (), one Segment, or a tuple of two to six. |
Segment | A type one {name} segment of a Route holds. |
derive(Segment) | Implements hypersig::Segment for an enum whose variants have no fields. |
Search | The search parameters of a Route: (), or a struct with #[derive(Signals, Search)]. |
SearchValue | A Search field type: a SearchScalar, or an Option or Vec of one. |
SearchScalar | A type that one value of the query string holds. |
derive(Search) | Checks that each field of a struct can be written into a query string. |
Rest | The rest of a path, from a {*name} segment at its end, which may hold /. |
Extends | Parameters that start with the parameters P of a parent Route. |
Link | A link to a Route, for El::href on the page whose signals are S. |
Link::navigate | A statement that loads the linked page, as following the link would. |
Link::push_url | A statement that shows the linked URL in the address bar as a new history entry. |
Link::replace_url | A statement that shows the linked URL in the address bar in place of the current one. |
Url | The URL of a page, written on the server by Route::url. |
SafeUrl | A URL whose scheme cannot run a script: http:, https:, mailto:, or none at all, as in /logo.png, #top, ?page=2, or //cdn.example/a.js. |
SafeUrl::parse | Reads a URL from outside the program, such as one a visitor typed. |
UnsafeUrl | Text that SafeUrl::parse refused, with the rule it broke. |