| Crates.io | hooch-http |
| lib.rs | hooch-http |
| version | 0.1.4 |
| created_at | 2025-03-22 22:01:38.325202+00 |
| updated_at | 2025-04-05 16:22:24.400208+00 |
| description | HTTP addition to the hooch runtime |
| homepage | |
| repository | https://github.com/bwintertkb/hooch-http |
| max_upload_size | |
| id | 1602134 |
| size | 66,610 |
hooch_http is a lightweight, asynchronous HTTP server framework built on top of the hooch runtime. It provides fast HTTP parsing, simple route matching, support for path/query parameters, and middleware integration—all with zero heap allocations for request parsing.
hooch for scalable, non-blocking I/O./user/{id}) and extract dynamic segments in a type-safe manner.use hooch::hooch_main;
use hooch_http::{HoochAppBuilder, HttpMethod, HttpResponseBuilder};
#[hooch_main]
async fn main() {
let mut app = HoochAppBuilder::new("localhost:8080").unwrap();
// Example middleware: Log incoming requests.
app.add_middleware(|req, addr| async move {
println!("Received request from {}: {:?}", addr, req);
hooch_http::Middleware::Continue(req)
});
// Add a GET route with parameter extraction.
app.add_route("/what/{mate}", HttpMethod::GET, |req, mut params| async move {
// Iterate over extracted path parameters.
for (key, value) in params.iter_path() {
println!("PATH KEY: {:?}", key);
println!("PATH VALUE: {:?}", value);
}
// Iterate over extracted query parameters.
for (key, value) in params.iter_query() {
println!("QUERY KEY: {:?}", key);
println!("QUERY VALUE: {:?}", value);
}
HttpResponseBuilder::ok()
.body("Hello from inside /what/{mate}".into())
.build()
});
let app = app.build();
app.serve().await;
}