1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
// FIXME: remove this feature gate as soon as the rustc version used in docs.rs is updated
#![cfg_attr(finchers_inject_extern_prelude, feature(extern_prelude))]

//! A combinator library for building asynchronous HTTP services.
//!
//! The concept and design was highly inspired by [`finch`](https://github.com/finagle/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
//!
//! ```no_run
//! #[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")
//! }
//! ```

#![doc(html_root_url = "https://docs.rs/finchers/0.13.5")]
#![warn(
    missing_docs,
    missing_debug_implementations,
    nonstandard_style,
    rust_2018_idioms,
    unused,
)]
// FIXME: re-enable the following lint after shipping rust-1.31 out
// #![warn(rust_2018_compatibility)]
#![cfg_attr(finchers_deny_warnings, deny(warnings))]
#![cfg_attr(finchers_deny_warnings, doc(test(attr(deny(warnings)))))]

#[macro_use]
extern crate bitflags;
extern crate bytes;
extern crate cookie;
extern crate either;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate futures;
extern crate http;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate mime;
extern crate mime_guess;
#[macro_use]
extern crate percent_encoding;
extern crate serde;
extern crate serde_json;
extern crate serde_qs;
extern crate tokio;
extern crate tokio_threadpool;
extern crate tower_service;
extern crate url;

#[cfg(feature = "tower-web")]
extern crate tower_web;

#[cfg(test)]
#[macro_use]
extern crate matches;

mod app;
mod common;

pub mod endpoint;
pub mod endpoints;
pub mod error;
pub mod input;
pub mod output;
pub mod rt;
pub mod server;
pub mod test;

/// A prelude for crates using the `finchers` crate.
pub mod prelude {
    pub use endpoint;
    pub use endpoint::wrapper::{EndpointWrapExt, Wrapper};
    pub use endpoint::{Endpoint, IntoEndpoint, IntoEndpointExt};
    pub use endpoints;
    pub use error::HttpError;
}