pub struct Router { /* private fields */ }Expand description
A compiled set of routes ready to answer requests.
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(routes: Vec<Route>) -> Result<Self, RouterError>
pub fn new(routes: Vec<Route>) -> Result<Self, RouterError>
Compile a set of routes.
Returns an error if any route has an invalid path pattern or an empty
sequence: [] response spec.
Sourcepub fn resolve(
&self,
method: Method,
path: &str,
query: &HashMap<String, String>,
headers: &HashMap<String, String>,
body: &Value,
) -> Option<Match>
pub fn resolve( &self, method: Method, path: &str, query: &HashMap<String, String>, headers: &HashMap<String, String>, body: &Value, ) -> Option<Match>
Resolve a request to a Match.
All inputs use plain, server-agnostic types. headers should use
lower-cased header names; header matching against route rules is
performed case-insensitively regardless.
For sequence routes, each successful match advances the internal counter; the last response in the sequence is repeated forever.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Router
impl RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
impl UnwindSafe for Router
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more