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
- Focusing on stable channel
References
Example
#[macro_use]
extern crate finchers;
use finchers::Endpoint;
fn build_endpoint() -> impl Endpoint<Output = String> + 'static {
use finchers::endpoint::prelude::*;
path("api/v1").right(choice![
get(param().unwrap_ok())
.map(|id: u64| format!("GET: id={}", id)),
post(body().unwrap_ok())
.map(|data: String| format!("POST: body={}", data)),
])
}
fn main() {
let endpoint = build_endpoint();
# std::thread::spawn(move || {
finchers::run(endpoint);
# });
}