Expand description
Convenience re-exports for writing handlers and running the server.
A single glob import covers the types you need in almost every handler:
use rust_web_server::prelude::*;
fn hello(_: &Request, _: &PathParams, _: &ConnectionInfo, _: &()) -> Response {
Response::text(STATUS_CODE_REASON_PHRASE.n200_ok, "Hello, world!")
}
fn main() {
let app = App::with_state(()).get("/hello", hello);
let (listener, pool) = Server::setup().unwrap();
Server::run(listener, pool, app);
}Macros§
- routes
- Build a routing app from a declarative table.
Structs§
- App
- The built-in HTTP application. Serves static files, favicons, forms, file uploads, health probes, metrics, and a 404 fallback.
- Connection
Info - Network context for the current connection, passed into every
Controller. - Mime
Type - MIME type constants and file-extension detection.
- Path
Params - Named path-segment values extracted from a matched route pattern.
- Range
- A byte range within a resource (
start..end). - Request
- A parsed HTTP request.
- Response
- An HTTP response. Build one inside [
Controller::process] and return it. - Server