pub struct Engine { /* private fields */ }Expand description
Engine that collects routes/middlewares and then starts the server.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(conf: RestConf) -> Result<Self>
pub fn new(conf: RestConf) -> Result<Self>
Create engine with RestConf; validates config. Create engine with RestConf and validate config.
Sourcepub fn add_routes<I>(&mut self, routes: I)where
I: IntoIterator<Item = Route>,
pub fn add_routes<I>(&mut self, routes: I)where
I: IntoIterator<Item = Route>,
Add multiple routes. Add multiple routes.
Sourcepub fn use_middleware(&mut self, middleware: Middleware)
pub fn use_middleware(&mut self, middleware: Middleware)
Register global middleware. Register global middleware.
Sourcepub fn set_not_found_handler(&mut self, handler: impl IntoHandler)
pub fn set_not_found_handler(&mut self, handler: impl IntoHandler)
Set custom 404 handler. Set custom 404 handler.
Sourcepub fn set_not_allowed_handler(&mut self, handler: impl IntoHandler)
pub fn set_not_allowed_handler(&mut self, handler: impl IntoHandler)
Set custom 405 handler. Set custom 405 handler.
Sourcepub async fn start(self) -> Result<ServerHandle>
pub async fn start(self) -> Result<ServerHandle>
Start server with collected routes/middlewares. Start server with collected routes and middlewares.
Sourcepub fn print_routes(&self)
pub fn print_routes(&self)
Print registered routes (method path). Print registered routes (method + path).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
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