fire-http 0.2.9

Http async library based on hyper and tokio
Documentation

CI crates.io docs.rs

A simple http server library.

Example

# use fire_http as fire;
use fire::{data_struct, get};

// To access data from request handlers
data_struct! {
	#[derive(Debug)]
	struct Data {
		global_name: String
	}
}

// handle a simple get request
get! {
	Root, "/",
	|_r, global_name| -> String {
		format!("Hi, this is {}", global_name)
	}
}

#[tokio::main]
async fn main() {
	let data = Data {
		global_name: "fire".into()
	};

	let mut server = fire::build("0.0.0.0:3000", data)
		.expect("Failed to parse address");

	server.add_route(Root);

	server.light().await
		.expect("server paniced");
}

For more examples look in the examples directory and the test directory.

Features

  • json
  • fs
  • encdec (adds percent encoding and decoding to header values)
  • http2 (enables http 2 support)
  • ws (adds websocket support)