diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs index adf13e3f..f8bd71b2 100644 --- a/actix-service/src/fn_service.rs +++ b/actix-service/src/fn_service.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use futures::future::{ok, FutureResult}; use futures::{Async, IntoFuture, Poll}; -use super::{IntoNewService, IntoService, NewService, Service}; +use super::{IntoConfigurableNewService, IntoNewService, IntoService, NewService, Service}; /// Create `NewService` for function that can act as Service pub fn fn_service(f: F) -> FnNewService @@ -266,13 +266,13 @@ where } } -// impl IntoNewService, C> for F -// where -// F: Fn(&C) -> R, -// R: IntoFuture, -// S: Service, -// { -// fn into_new_service(self) -> FnNewServiceConfig { -// FnNewServiceConfig::new(self) -// } -// } +impl IntoConfigurableNewService, C> for F +where + F: Fn(&C) -> R, + R: IntoFuture, + S: Service, +{ + fn into_new_service(self) -> FnNewServiceConfig { + FnNewServiceConfig::new(self) + } +} diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index 3e5cd52a..02603dbd 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -437,3 +437,21 @@ where self } } + +/// Trait for types that can be converted to a configurable `NewService` +pub trait IntoConfigurableNewService +where + T: NewService, +{ + /// Convert to an `NewService` + fn into_new_service(self) -> T; +} + +impl IntoConfigurableNewService for T +where + T: NewService, +{ + fn into_new_service(self) -> T { + self + } +}