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() -> finchers::server::ServerResult<()> {
    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::server::start(post_api)
        .serve("127.0.0.1:4000")
}

Modules

endpoint

Components for constructing Endpoint.

endpoints

Built-in endpoints.

error

Error primitives.

input

Components for parsing the incoming HTTP request.

output

Components for constructing HTTP responses.

prelude

A prelude for crates using the finchers crate.

rt

Components for working with Finchers runtime.

server

The implementation of HTTP server based on hyper and tower-service.

test

The basic facilities for testing endpoints.

Macros

path

A helper macro for creating an endpoint which matches to the specified HTTP path.

routes

A helper macro for creating the instance ofEndpoint from multiple routes.