Crates.io | blaze |
lib.rs | blaze |
version | 0.1.6 |
source | src |
created_at | 2024-09-14 19:41:01.186733 |
updated_at | 2024-09-17 05:24:09.566089 |
description | blazing fast http framework |
homepage | |
repository | |
max_upload_size | |
id | 1375007 |
size | 33,598 |
Blaze is a lightweight, asynchronous web framework for Rust, designed for simplicity and performance.
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)?
}
http://localhost:8080/hello/world
in your browser.