luminal_router/
lib.rs

1//! Router for mapping `hyper::Method` and a request path to something that will response.
2//!
3//! luminal's router uses a simplified radix tree for speedy lookups. `cargo +nightly bench` to see
4//! relative performance across some contrived examples.
5//!
6//! The actual router implementation depends on the features used to build the crate. By default,
7//! the `Router` implementation works with `hyper::server::Service`. Using the "handler" feature
8//! switches to a `Router` that is aware of the luminal-handler create.
9#[macro_use]
10extern crate error_chain;
11extern crate futures;
12#[cfg(feature = "handler")]
13extern crate http;
14extern crate hyper;
15#[cfg(feature = "handler")]
16extern crate luminal_handler;
17
18mod error;
19mod route;
20mod tree;
21#[cfg(feature = "handler")]
22mod handler;
23#[cfg(not(feature = "handler"))]
24mod service;
25
26use futures::future::Future;
27use hyper::server::Response;
28#[cfg(not(feature = "handler"))]
29use hyper::server::{Request, Service};
30
31#[cfg(feature = "handler")]
32pub use handler::{FnRouteBuilder, HandlerRouteBuilder, Router};
33#[cfg(not(feature = "handler"))]
34pub use service::{FnRouteBuilder, Router, ServiceRouteBuilder};
35
36pub use error::Error as LuminalError;
37pub use error::ErrorKind as LuminalErrorKind;
38
39/// Convenience, especially for `hyper::service::service_fn`.
40pub type LuminalFuture = Box<Future<Item = Response, Error = hyper::Error>>;
41
42#[cfg(not(feature = "handler"))]
43type LuminalService =
44    Service<Request = Request, Response = Response, Error = hyper::Error, Future = LuminalFuture>;