1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Trout is a tree-based routing library.
//! It is fairly generic, but designed to be used for HTTP servers.

#![warn(missing_docs)]

#[cfg(feature = "hyper")]
pub mod hyper;
mod internal;
pub mod node;

pub use node::Node;

#[derive(Debug, Clone, Copy)]
/// Ways that routing can fail
pub enum RoutingFailure {
    /// No node was found for the request path
    NotFound,
    /// No handler was found for the request method
    MethodNotAllowed,
}

/// Trait to represent a Request which can be handled
pub trait Request {
    /// Path of request. Should *not* have a leading slash.
    fn path<'a>(&'a self) -> &'a str;
    /// Request method, as in HTTP
    fn method<'a>(&'a self) -> &'a str;
}