haro/lib.rs
1//! # Haro
2//!
3//! Haro is a **simple** and **synchronous** web framework written in and for Rust.
4//!
5//! ## Features
6//!
7//! - URL Routing with **function**/**closure**/**trait type**
8//! - Request & Response with minimal boilerplate
9//! - Query args
10//! - Post data
11//! - JSON
12//! - Cookie
13//! - Middleware
14//! - Template (optional)
15//! - Database (optional)
16//! - Tests
17//!
18//! ## Example
19//!
20//! The "Hello, World!" of Haro is:
21//!
22//! ```rust,no_run
23//! use haro::{Application, Request, Response};
24//!
25//! fn main() {
26//! let mut app = Application::new("0:8000");
27//! app.route("/", hello);
28//! app.run();
29//! }
30//!
31//! fn hello(_: Request) -> Response {
32//! Response::str("Hello Haro")
33//! }
34//! ```
35//!
36//! ## Optional Features
37//!
38//! Haro uses a set of [feature flags] to reduce the amount of compiled code and
39//! optional dependencies.
40//!
41//! You can also use the `full` feature flag which will enable all public APIs.
42//! Beware that this will pull in many extra dependencies that you may not need.
43//!
44//! The following optional features are available:
45//!
46//! - `database`: Enables Database support.
47//! - `template`: Enables Template support.
48//!
49//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
50//!
51//! ## Examples
52//!
53//! The Haro repo contains [a number of examples][examples] that show how to put all the
54//! pieces together.
55//!
56//! [examples]: https://github.com/shellfly/haro/tree/main/examples
57//!
58mod app;
59mod http;
60pub mod middleware;
61mod pool;
62mod router;
63
64pub use crate::app::Application;
65pub use crate::http::request::Request;
66pub use crate::http::response::{redirect, Response};
67pub use crate::router::{DynHandler, Handler};
68
69#[cfg(feature = "template")]
70mod template;
71
72#[cfg(feature = "database")]
73pub mod db;