A combinator library for building asynchronous HTTP services.
The concept and design was highly inspired by finch
.
Features
- Asynchronous handling powerd by futures and Tokio
- Building an HTTP service by combining the primitive components
- Type-safe routing without (unstable) procedural macros
Example
#[macro_use]
extern crate finchers;
use finchers::prelude::*;
fn main() {
let get_post = path!(@get / u64 /)
.map(|id: u64| format!("GET: id={}", id));
let create_post = path!(@post /)
.and(endpoints::body::text())
.map(|data: String| format!("POST: body={}", data));
let post_api = path!(/ "posts")
.and(get_post.or(create_post));
finchers::launch(post_api)
.start("127.0.0.1:4000");
}