Crate fire_http

Source
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§

pub use error::Error;
pub use error::Result;
pub use extractor::Res;
pub use types;

Modules§

body
error
extractor
fsfs
graphqlgraphql
header
into
jsonjson
resources
routes
service
state
util
wsws

Macros§

extractor_extract
extractor_prepare
extractor_validate
impl_req_extractor
impl_res_extractor
memory_filefs
Static get handler which servers/returns a file which gets loaded into the binary at compile time.

Structs§

Body
Fire
A Fire that is ready to be ignited.
FireBuilder
FireBuilder gathers all materials needed to light a fire (start a server).
FirePit
Request
The request that is received from a client.
Response
The response created from a server.

Functions§

build
Prepares a server.

Attribute Macros§

delete
delete_json
get
get_json
head
head_json
post
post_json
put
put_json
ws

Derive Macros§

Resource