Skip to main content

match_path

Function match_path 

Source
pub fn match_path(
    path: &str,
    keys: &[String],
    entry: &str,
) -> Option<(String, String)>
Expand description

The page path names and the part of the path that page answers for, or None when no page answers for it.

Algorithm - the framework does not pattern-match segments:

  1. Strip a leading /. An empty path names entry (the home page).
  2. Try the full path as a page key; if absent, walk up one segment at a time to the longest existing prefix (/user/7 -> user when only user.lmn exists).
  3. The leftover tail after the matched prefix becomes the segment (/7), for the page’s own code to parse.

Use this where an address that names nothing has an answer of its own, such as a server sending a 404. Somewhere that has to show a page either way, such as a window following a link, wants resolve_path.