Skip to main content

rust_web_server/application/
mod.rs

1use crate::request::Request;
2use crate::response::Response;
3use crate::server::ConnectionInfo;
4
5#[cfg(test)]
6mod example;
7
8/// Dispatch trait that wires controllers into a request-handling loop.
9///
10/// Implement this to define which controllers run and in what order.
11/// Pass the implementation to [`Server::run`] or [`Server::run_tls`].
12///
13/// The built-in [`App`](crate::app::App) implementation covers static files,
14/// favicons, forms, and file uploads. Embed it or replace it entirely.
15pub trait Application {
16    /// Receives a parsed request and returns a fully-built response.
17    /// Walk your controller list with `is_matching` / `process` and return the first match.
18    fn execute(&self, request: &Request, connection: &ConnectionInfo) -> Result<Response, String>;
19}