pub struct App { /* private fields */ }Expand description
Your app’s starting point - where all the magic happens
Implementations§
Source§impl App
Convenience methods for App to add documented endpoints
impl App
Convenience methods for App to add documented endpoints
Sourcepub fn documented_get<H, T>(
self,
path: &str,
handler: H,
doc: EndpointDoc,
) -> Selfwhere
H: Handler<T>,
pub fn documented_get<H, T>(
self,
path: &str,
handler: H,
doc: EndpointDoc,
) -> Selfwhere
H: Handler<T>,
Add a documented GET endpoint
Sourcepub fn documented_post<H, T>(
self,
path: &str,
handler: H,
doc: EndpointDoc,
) -> Selfwhere
H: Handler<T>,
pub fn documented_post<H, T>(
self,
path: &str,
handler: H,
doc: EndpointDoc,
) -> Selfwhere
H: Handler<T>,
Add a documented POST endpoint
Source§impl App
impl App
Sourcepub fn with_state<T>(self, state: T) -> Self
pub fn with_state<T>(self, state: T) -> Self
Add application state that can be accessed in handlers
Sourcepub fn middleware<M>(self, middleware: M) -> Selfwhere
M: Middleware,
pub fn middleware<M>(self, middleware: M) -> Selfwhere
M: Middleware,
Stack up middleware for request processing
Sourcepub fn route<H, T>(self, method: Method, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn route<H, T>(self, method: Method, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Map any HTTP method to a path with your handler
Sourcepub fn get<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn get<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle GET requests - perfect for serving pages and fetching data
Sourcepub fn post<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn post<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle POST requests - for creating new resources
Sourcepub fn put<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn put<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle PUT requests - for updating entire resources
Sourcepub fn delete<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn delete<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle DELETE requests - for removing resources
Sourcepub fn patch<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn patch<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle PATCH requests - for partial updates
Sourcepub fn options<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn options<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle OPTIONS requests - usually for CORS preflight
Sourcepub fn head<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
pub fn head<H, T>(self, path: &str, handler: H) -> Selfwhere
H: Handler<T>,
Handle HEAD requests - like GET but without the body
Sourcepub fn not_found<H, T>(self, handler: H) -> Selfwhere
H: Handler<T>,
pub fn not_found<H, T>(self, handler: H) -> Selfwhere
H: Handler<T>,
Catch requests that don’t match any route
Sourcepub fn mount(self, prefix: &str, other: Router) -> Self
pub fn mount(self, prefix: &str, other: Router) -> Self
Mount another router at a specific path prefix
Sourcepub fn error_pages(self, error_pages: ErrorPages) -> Self
pub fn error_pages(self, error_pages: ErrorPages) -> Self
Configure error pages
Sourcepub fn custom_404(self, html: String) -> Self
pub fn custom_404(self, html: String) -> Self
Set a custom 404 page
Sourcepub fn custom_500(self, html: String) -> Self
pub fn custom_500(self, html: String) -> Self
Set a custom 500 page
Sourcepub fn plain_error_pages(self) -> Self
pub fn plain_error_pages(self) -> Self
Disable default error page styling (use plain HTML)
Source§impl App
Pre-configured apps for common scenarios
impl App
Pre-configured apps for common scenarios
Sourcepub fn with_logging() -> Self
pub fn with_logging() -> Self
Create a new app with logging middleware
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a production-ready app with security, monitoring, and performance middleware
Sourcepub fn with_security() -> Self
pub fn with_security() -> Self
Create an app with basic security features
Sourcepub fn with_monitoring() -> Self
pub fn with_monitoring() -> Self
Create an app with monitoring and metrics