Crate finchers[−][src]
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"); }
Modules
endpoint |
Components for constructing |
endpoints |
Built-in endpoints. |
error |
Error primitives. |
input |
Components for parsing the incoming HTTP request. |
launcher |
Components for managing HTTP server. |
local |
Utilities for testing endpoints. |
output |
Components for constructing HTTP responses. |
prelude |
A prelude for crates using the |
Macros
impl_endpoint | |
path |
A helper macro for creating an endpoint which matches to the specified HTTP path. |
routes |
A helper macro for creating the instance of |
Functions
launch |
Create an instance of |