/// Adds route to routing map.
///
/// Its easier to the the helper functions.
///
/// # Examples
///
/// ## Simple
///
/// ```rust
/// # use direkuta::prelude::*;
/// # use direkuta::prelude::hyper::*;
/// Direkuta::new()
///     .route(|r| {
///         r.route(Method::GET, "/", |_, _, _| {
///             Response::new().with_body("Hello World!").build()
///         });
///     });
/// ```
///
/// ```rust,ignore
/// "/" {
///     GET => "Hello World!"
/// }
/// ```
///
/// ## Regex
///
/// ```rust
/// # use direkuta::prelude::*;
/// # use direkuta::prelude::hyper::*;
/// Direkuta::new()
///     .route(|r| {
///         r.route(Method::GET, "/<name:(.*)>", |_, _, c| {
///             Response::new().with_body(c.get("name")).build()
///         });
///     });
/// ```
///
/// ```rust,ignore
/// "/txuritan" : { "name" => "txuritan" } {
///     GET => "txuritan"
/// }
/// ```
Adds route to routing map.
Its easier to the the helper functions.
Adds route to routing map . Its easier to the the helper functions .
pub fn route(
        &mut self,
        method: Method,
        path: impl Into<String>,
        handler: impl Fn(Request, Arc<State>, Capture)
                -> Box<dyn Future<Item = response::Response<Body>, Error = DireError> + Send + 'static>
            + Send
            + Sync
            + 'static,
    ) {
        let path = path.into();
        // Transform the path in to ids and regex
        let reader = self.read(&path);
        self.inner.entry(method).or_insert(Vec::new()).push(Route {
            handler: Box::new(handler),
            ids: reader.0,
            path,
            pattern: reader.1,
        });
    }
pub fn route ( & mut self , method : Method , path : impl Into < String > , handler : impl Fn ( Request , Arc < State > , Capture ) -> Box < dyn Future < Item = response :: Response < Body > , Error = DireError > + Send + ' static > + Send + Sync + ' static , ) { let path = path . into ( ) ; // Transform the path in to ids and regex let reader = self . read ( & path ) ; self . inner . entry ( method ) . or_insert ( Vec :: new ( ) ) . push ( Route { handler : Box :: new ( handler ) , ids : reader . 0 , path , pattern : reader . 1 , } ) ; }
Adds route to routing map.
Adds route to routing map .
&mut self
method
Method
path
impl Into<String>
handler
impl Fn(Request, Arc<State>, Capture)
                -> Box<dyn Future<Item = response::Response<Body>, Error = DireError> + Send + 'static>
            + Send
            + Sync
            + 'static
examples
None
simple
None
use direkuta::prelude::*;
None
use direkuta::prelude::hyper::*;
None
regex
None
use direkuta::prelude::*;
None
use direkuta::prelude::hyper::*;
None