Crates.io | fire-http |
lib.rs | fire-http |
version | 0.5.0 |
source | src |
created_at | 2020-03-17 00:15:00.819791 |
updated_at | 2024-06-13 21:34:01.134601 |
description | Http async library based on hyper and tokio |
homepage | |
repository | https://github.com/fire-lib/fire-http |
max_upload_size | |
id | 219661 |
size | 153,866 |
A simple http server library.
# use fire_http as fire;
use fire::{get, Res};
struct GlobalName(String);
// handle a simple get request
#[get("/")]
fn root(global_name: Res<GlobalName>) -> String {
format!("Hi, this is {}", global_name.0)
}
#[tokio::main]
async fn main() {
let mut server = fire::build("0.0.0.0:3000").await
.expect("Failed to parse address");
server.add_data(GlobalName("fire".into()));
server.add_route(root);
server.ignite().await.unwrap();
}
For more examples look in the examples directory and the test directory.