pub struct RouteTable { /* private fields */ }Expand description
The set of routes registered on an application.
Implementations§
Source§impl RouteTable
impl RouteTable
Sourcepub fn register(&mut self, method: &str, pattern: &str, meta: RouteMeta)
pub fn register(&mut self, method: &str, pattern: &str, meta: RouteMeta)
Register a method on a path.
Registering the same method twice replaces its metadata, which is how a route is redefined.
Sourcepub fn remove(&mut self, method: &str, pattern: &str)
pub fn remove(&mut self, method: &str, pattern: &str)
Remove a method from a path, dropping the path when it keeps none.
Used by crate::app::LinoApp::without_description to withdraw the
description routes the constructor registers.
Sourcepub fn find(&self, pathname: &str) -> Option<&RouteEntry>
pub fn find(&self, pathname: &str) -> Option<&RouteEntry>
Find the route entry owning a concrete path.
Sourcepub fn match_path(&self, pathname: &str) -> Option<(&RouteEntry, PathParams)>
pub fn match_path(&self, pathname: &str) -> Option<(&RouteEntry, PathParams)>
Find the route entry owning a path together with its path parameters.
Routes are tried in registration order, so an earlier registration wins.
Sourcepub fn allowed_methods(&self, pathname: &str) -> Option<Vec<String>>
pub fn allowed_methods(&self, pathname: &str) -> Option<Vec<String>>
List the methods allowed on a concrete path.
OPTIONS is always allowed, and HEAD is allowed wherever GET is.
The answer is None when no route owns the path.
Sourcepub fn allowed_methods_of(&self, entry: &RouteEntry) -> Vec<String>
pub fn allowed_methods_of(&self, entry: &RouteEntry) -> Vec<String>
The methods allowed on a route entry, sorted.
Sourcepub fn entries(&self) -> &[RouteEntry]
pub fn entries(&self) -> &[RouteEntry]
The registered routes, in registration order.
Sourcepub fn describe(&self) -> Vec<RouteDescription>
pub fn describe(&self) -> Vec<RouteDescription>
Render the registry as the routes member of a service description.
Routes are ordered by path, so two servers describing the same routes describe them identically.