feat(server): add const_service and service_fn helpers

- `const_service` creates a `NewService` that clones references to the
  wrapped service.
- `service_fn` creates a `Service` from a function. Useful with closures.
This commit is contained in:
Sean McArthur
2017-11-09 16:47:35 -08:00
parent 68e0df759a
commit fe38aa4bc1
3 changed files with 78 additions and 23 deletions

View File

@@ -7,6 +7,7 @@
mod compat_impl;
#[cfg(feature = "compat")]
pub mod compat;
mod service;
use std::cell::RefCell;
use std::fmt;
@@ -46,6 +47,8 @@ feat_server_proto! {
};
}
pub use self::service::{const_service, service_fn};
/// An instance of the HTTP protocol, and implementation of tokio-proto's
/// `ServerProto` trait.
///