pub struct Server { /* private fields */ }Expand description
Lightweight web server built on hyper.
Implementations§
Source§impl Server
impl Server
pub fn new(conf: RestConf) -> Self
Sourcepub fn add_routes<I>(&mut self, routes: I) -> &mut Selfwhere
I: IntoIterator<Item = Route>,
pub fn add_routes<I>(&mut self, routes: I) -> &mut Selfwhere
I: IntoIterator<Item = Route>,
Register routes (in-place, chain-friendly).
pub fn set_debug_group(&mut self, name: impl Into<String>)
pub fn clear_debug_group(&mut self)
Sourcepub fn use_middleware(&mut self, middleware: Middleware) -> &mut Self
pub fn use_middleware(&mut self, middleware: Middleware) -> &mut Self
Register global middleware applied to all routes.
Sourcepub fn with_middlewares<I>(&mut self, middlewares: I) -> &mut Selfwhere
I: IntoIterator<Item = Middleware>,
pub fn with_middlewares<I>(&mut self, middlewares: I) -> &mut Selfwhere
I: IntoIterator<Item = Middleware>,
Chain-friendly append for global middlewares.
Sourcepub fn with_middleware(&mut self, middleware: Middleware) -> &mut Self
pub fn with_middleware(&mut self, middleware: Middleware) -> &mut Self
Chain-friendly append for a single global middleware.
Sourcepub fn set_not_found_handler(&mut self, handler: HandlerFunc)
pub fn set_not_found_handler(&mut self, handler: HandlerFunc)
Set custom 404 handler.
Sourcepub fn set_not_allowed_handler(&mut self, handler: HandlerFunc)
pub fn set_not_allowed_handler(&mut self, handler: HandlerFunc)
Set custom 405 handler.
Sourcepub fn with_root_prefix(&mut self, prefix: impl Into<String>) -> &mut Self
pub fn with_root_prefix(&mut self, prefix: impl Into<String>) -> &mut Self
Set root prefix (replaces previous prefix chain).
Sourcepub fn with_prefix(&mut self, prefix: impl Into<String>) -> &mut Self
pub fn with_prefix(&mut self, prefix: impl Into<String>) -> &mut Self
Append prefix (can be chained).
Sourcepub async fn start(self) -> Result<ServerHandle>
pub async fn start(self) -> Result<ServerHandle>
Deprecated aliases removed to keep pure Rust naming. Start HTTP server and return controllable handle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
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