Skip to main content

rust_web_server/prelude/
mod.rs

1//! Convenience re-exports for writing handlers and running the server.
2//!
3//! A single glob import covers the types you need in almost every handler:
4//!
5//! ```rust,no_run
6//! use rust_web_server::prelude::*;
7//!
8//! fn hello(_: &Request, _: &PathParams, _: &ConnectionInfo, _: &()) -> Response {
9//!     Response::text(STATUS_CODE_REASON_PHRASE.n200_ok, "Hello, world!")
10//! }
11//!
12//! fn main() {
13//!     let app = App::with_state(()).get("/hello", hello);
14//!     let (listener, pool) = Server::setup().unwrap();
15//!     Server::run(listener, pool, app);
16//! }
17//! ```
18
19pub use crate::app::App;
20pub use crate::core::New;
21pub use crate::mime_type::MimeType;
22pub use crate::range::Range;
23pub use crate::request::Request;
24pub use crate::response::{Response, STATUS_CODE_REASON_PHRASE};
25pub use crate::router::PathParams;
26pub use crate::routes;
27pub use crate::server::ConnectionInfo;
28#[cfg(not(target_arch = "wasm32"))]
29pub use crate::server::Server;