Skip to content

module

router

Path matching for client-side (hash) routing.

The browser side (weft::web::hash_route) exposes the current location.hash as a signal; Router maps it to a route and parameters: "/post/:slug", "/docs/*" (the rest as *), "/docs/*path" (the rest as path), "*".

Structs

  • RouteMatch

    A successful route match.

  • Router

    An ordered list of route patterns; the first match wins.

Functions

match_route

pub fn match_route(pattern: &str, path: &str) -> Option<BTreeMap<String, String>>

Match path against pattern, returning captured parameters.

split_location

pub fn split_location(hash: &str) -> (String, BTreeMap<String, String>)

Split location.hash (#/a/b?x=1) into a path and query parameters.