Struct pillow_routing::MainRouter
source · pub struct MainRouter { /* private fields */ }
Expand description
The Main router in your app
#[tokio::main]
async fn main(){
let mut router = MainRouter::new();
}
Implementations§
source§impl MainRouter
impl MainRouter
source§impl MainRouter
impl MainRouter
pub fn add_route_closure<T>( &mut self, method: HttpMethods, path: &str, controller: T )where T: Fn(&Request) -> Response + Send + Sync + 'static,
sourcepub fn add_route(&mut self, route: Route)
pub fn add_route(&mut self, route: Route)
Add Route
Arguments
uri
- Path of routecontroller
- Callback function
Examples
use pillow::http::*;
#[controller(method = "GET", path = "/")]
fn index (_: Request) -> Response {
Response::text("hello")
}
#[tokio::main]
async fn main (){
let mut router = MainRouter::new();
router.add_route(route!(index {}));
}
Auto Trait Implementations§
impl !RefUnwindSafe for MainRouter
impl Send for MainRouter
impl Sync for MainRouter
impl Unpin for MainRouter
impl !UnwindSafe for MainRouter
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