pub fn path(
        &mut self,
        path: impl Into<String>,
        sub: impl Fn(&mut Router) + Send + Sync + 'static,
    ) {
        let mut builder = Router::new();

        sub(&mut builder);

        let path = path.into();

        // Loop through new methods
        for (method, routes) in builder.inner {
            // Loop through new routes
            for route in routes {
                // Concatenate paths
                let n_path = format!("{}{}", path, route.path);

                // Transform the path in to ids and regex
                let reader = self.read(&n_path);

                self.inner
                    .entry(method.clone())
                    .or_insert(Vec::new())
                    .push(Route {
                        handler: route.handler,
                        ids: reader.0,
                        path: n_path,
                        pattern: reader.1,
                    });
            }
        }
    }
/// Create a path for multiple request types.
///
/// # Examples
///
/// ## Simple
///
/// ```rust
/// # use direkuta::prelude::*;
/// Direkuta::new()
///     .route(|r| {
///         r.path("/parent", |r| {
///             r.get("/child", |_, _, _| {
///                 Response::new().with_body("Hello World!").build()
///             });
///         });
///     });
/// ```
///
/// ```rust,ignore
/// "/parent/child" : {  } {
///     GET => "Hello World!"
/// }
/// ```
Create a path for multiple request types.
Create a path for multiple request types .
pub fn path(
        &mut self,
        path: impl Into<String>,
        sub: impl Fn(&mut Router) + Send + Sync + 'static,
    ) {
        let mut builder = Router::new();
        sub(&mut builder);
        let path = path.into();
        // Loop through new methods
        for (method, routes) in builder.inner {
            // Loop through new routes
            for route in routes {
                // Concatenate paths
                let n_path = format!("{}{}", path, route.path);
                // Transform the path in to ids and regex
                let reader = self.read(&n_path);
                self.inner
                    .entry(method.clone())
                    .or_insert(Vec::new())
                    .push(Route {
                        handler: route.handler,
                        ids: reader.0,
                        path: n_path,
                        pattern: reader.1,
                    });
            }
        }
    }
pub fn path ( & mut self , path : impl Into < String > , sub : impl Fn ( & mut Router ) + Send + Sync + ' static , ) { let mut builder = Router :: new ( ) ; sub ( & mut builder ) ; let path = path . into ( ) ; // Loop through new methods for ( method , routes ) in builder . inner { // Loop through new routes for route in routes { // Concatenate paths let n_path = format ! ( " " path route path ) ; // Transform the path in to ids and regex let reader = self . read ( & n_path ) ; self . inner . entry ( method . clone ( ) ) . or_insert ( Vec :: new ( ) ) . push ( Route { handler : route . handler , ids : reader . 0 , path : n_path , pattern : reader . 1 , } ) ; } } }
Create a path for multiple request types.
Create a path for multiple request types .
&mut self
path
impl Into<String>
sub
impl Fn(&mut Router) + Send + Sync + 'static
&mut self
path
impl Into<String>
sub
impl Fn(&mut Router) + Send + Sync + 'static
examples
None
simple
None
use direkuta::prelude::*;
None