4 releases
0.1.6 | Sep 17, 2024 |
---|---|
0.1.5 | Sep 17, 2024 |
0.1.4 | Sep 14, 2024 |
0.1.3 | Sep 14, 2024 |
#1177 in HTTP server
34KB
842 lines
Blaze
Blaze is a lightweight, asynchronous web framework for Rust, designed for simplicity and performance.
Features
- Asynchronous request handling
- Routing with support for path parameters
- JSON serialization and deserialization
- Easy-to-use macros for defining routes
Quick Start
-
Add Blaze to your
Cargo.toml
-
Create a simple web server:
use blaze::{prelude::*, routes, Json};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Hello {
name: &'static str,
message: String,
}
#[blaze::route(get, "/hello/{name}")]
async fn hello(_req: Request, name: String) -> Json<Hello> {
Json(Hello {
name: "Blaze",
message: format!("Hello, {}!", name),
})
}
#[blaze::main]
fn main() {
let router = routes! {
hello,
};
Server::bind("127.0.0.1", 8080).serve(router)?
}
- Run your server and visit
http://localhost:8080/hello/world
in your browser.
Dependencies
~5–11MB
~123K SLoC