torus_http/lib.rs
1//! # toy-rusttp
2//!
3//! A small, synchronous http server library with a surprisingly pleasant
4//! developer experience and minimal moving parts.
5//!
6//! ## Example usage:
7//!
8//! ```no_run
9//! use torus_http::prelude::*;
10//!
11//! fn main() {
12//! let server: HttpServer = HttpServer::new()
13//! .get("/", hello_world)
14//! .route(
15//! "/hello",
16//! HttpMethod::other("custom"),
17//! |_| "hello from a custom method",
18//! )
19//! .add_middleware(|req| {
20//! println!("got request: {req:#?}");
21//! req
22//! });
23//!
24//! server
25//! .listen(("127.0.0.1", 8080))
26//! .expect("Failed listening...");
27//! }
28//!
29//! pub fn hello_world(req: HttpRequest) -> impl Response {
30//! HttpResponse::new()
31//! .set_body(format!(
32//! "<h1>hey there from torus!</h1><p>this is a test, your request is: {req:#?}</p>",
33//! ))
34//! .insert_header("Content-Type", "text/html")
35//! }
36//! ```
37
38pub mod method;
39pub mod prelude;
40pub mod request;
41pub mod response;
42pub mod server;
43pub mod status;