Skip to main content

Crate use_route

Crate use_route 

Source
Expand description

§use-route

Small route and path utilities for RustUse.

§Experimental

use-route is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

§Example

use use_route::{extract_route_params, matches_route_pattern, normalize_route};

assert_eq!(normalize_route("//users//42/"), "/users/42");
assert!(matches_route_pattern("/users/:id", "/users/42"));
assert_eq!(extract_route_params("/users/:id", "/users/42")[0].value, "42");

§Scope

  • Route normalization and joining.
  • Simple segment splitting and depth counting.
  • Lightweight :param pattern matching.

§Non-goals

  • Full routers.
  • Middleware.
  • Regex route engines.
  • Server implementations.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

RouteParam
A captured route parameter.
RouteSegment
A normalized route segment.

Functions§

extract_route_params
Extracts named route parameters when a pattern matches.
is_absolute_route
Returns true when the route is absolute.
join_routes
Joins two route fragments with exactly one slash.
matches_route_pattern
Returns true when a simple :param pattern matches the path.
normalize_route
Normalizes repeated slashes and removes trailing slashes except for the root route.
route_depth
Returns the number of non-empty route segments.
split_route
Splits a route into normalized segments.