Expand description
A simple http server library.
§Example
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.
§Features
- json
- fs
- http2 (enables http 2 support)
- ws (adds websocket support)
- trace
Re-exports§
Modules§
Macros§
- Static get handler which servers/returns a file which gets loaded into the binary at compile time.
Structs§
- A Fire that is ready to be ignited.
FireBuilder
gathers all materials needed to light a fire (start a server).- The request that is received from a client.
- The response created from a server.
Functions§
- Prepares a server.