Expand description

A basic path-matching language.

Examples

Path schemes may match literal paths:

assert!("/users/new".parse::<PathScheme>()
    .unwrap()
    .matches("/users/new")
    .unwrap()
    .is_empty());

Literal path matching is case-sensitive:

assert!("/users/new".parse::<PathScheme>()
    .unwrap()
    .matches("/users/New")
    .is_none());

Or they may capture path segments:

let matches = "/users/:id".parse::<PathScheme>()
    .unwrap()
    .matches("/users/olix0r")
    .unwrap();
assert!(matches.get("id").unwrap() == "olix0r");

Path schemes must match the entire path:

assert!("/users/:id".parse::<PathScheme>()
    .unwrap()
    .matches("/users/olix0r/dogs")
    .is_none());

A ** glob operator may be used to match path prefixes:

assert!("/users/:id/**".parse::<PathScheme>()
    .unwrap()
    .matches("/users/olix0r")
    .is_some());
assert!("/users/:id/**".parse::<PathScheme>()
    .unwrap()
    .matches("/users/olix0r/dogs")
    .is_some());

Structs

Describes a path scheme that may match one or paths.

Enums

Indicates an error encountered when parsing a path scheme.