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
Sourcepub fn new() -> MainRouter
pub fn new() -> MainRouter
Instance of a router
Source§impl MainRouter
impl MainRouter
pub fn add_route_closure<T>( &mut self, method: HttpMethods, path: &str, controller: T, )
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 Freeze for MainRouter
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