diff --git a/.travis.yml b/.travis.yml index d994a80d4..1d3c227a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,6 @@ before_script: script: - cargo clean - - cargo check - cargo test -- --nocapture # Upload docs diff --git a/src/app.rs b/src/app.rs index 2a2380b21..c9c23d9cb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -188,13 +188,13 @@ where > where M: NewTransform< - AppService
, + AppRouting
, Request = ServiceRequest
,
Response = ServiceResponse,
Error = (),
InitError = (),
>,
- F: IntoNewTransform {
+pub struct AppRoutingFactory {
services: Rc {
+impl {
type Request = ServiceRequest ;
type Response = ServiceResponse;
type Error = ();
type InitError = ();
- type Service = AppService ;
- type Future = CreateAppService ;
+ type Service = AppRouting ;
+ type Future = AppRoutingFactoryResponse ;
fn new_service(&self, _: &()) -> Self::Future {
- CreateAppService {
+ AppRoutingFactoryResponse {
fut: self
.services
.iter()
.map(|(path, service)| {
- CreateAppServiceItem::Future(
+ CreateAppRoutingItem::Future(
Some(path.clone()),
service.new_service(&()),
)
@@ -510,17 +510,17 @@ type HttpServiceFut = Box {
- fut: Vec {
+ fut: Vec {
+enum CreateAppRoutingItem {
Future(Option ),
Service(ResourceDef, HttpService ),
}
-impl Future for CreateAppService {
- type Item = AppService ;
+impl Future for AppRoutingFactoryResponse {
+ type Item = AppRouting ;
type Error = ();
fn poll(&mut self) -> Poll Future for CreateAppService {
// poll http services
for item in &mut self.fut {
let res = match item {
- CreateAppServiceItem::Future(ref mut path, ref mut fut) => {
+ CreateAppRoutingItem::Future(ref mut path, ref mut fut) => {
match fut.poll()? {
Async::Ready(service) => Some((path.take().unwrap(), service)),
Async::NotReady => {
@@ -538,11 +538,11 @@ impl Future for CreateAppService {
}
}
}
- CreateAppServiceItem::Service(_, _) => continue,
+ CreateAppRoutingItem::Service(_, _) => continue,
};
if let Some((path, service)) = res {
- *item = CreateAppServiceItem::Service(path, service);
+ *item = CreateAppRoutingItem::Service(path, service);
}
}
@@ -552,14 +552,14 @@ impl Future for CreateAppService {
.drain(..)
.fold(Router::build(), |mut router, item| {
match item {
- CreateAppServiceItem::Service(path, service) => {
+ CreateAppRoutingItem::Service(path, service) => {
router.rdef(path, service)
}
- CreateAppServiceItem::Future(_, _) => unreachable!(),
+ CreateAppRoutingItem::Future(_, _) => unreachable!(),
}
router
});
- Ok(Async::Ready(AppService {
+ Ok(Async::Ready(AppRouting {
router: router.finish(),
ready: None,
}))
@@ -569,12 +569,12 @@ impl Future for CreateAppService {
}
}
-pub struct AppService {
+pub struct AppRouting {
router: Router , ResourceInfo)>,
}
-impl Service for AppService {
+impl Service for AppRouting {
type Request = ServiceRequest ;
type Response = ServiceResponse;
type Error = ();
@@ -599,12 +599,13 @@ impl Service for AppService {
}
#[doc(hidden)]
+/// Wrapper service for routing
pub struct AppEntry {
- factory: Rc AppEntry {
- fn new(factory: Rc {
type Response = ServiceResponse;
type Error = ();
type InitError = ();
- type Service = AppService ;
- type Future = CreateAppService ;
+ type Service = AppRouting ;
+ type Future = AppRoutingFactoryResponse ;
fn new_service(&self, _: &()) -> Self::Future {
self.factory.borrow_mut().as_mut().unwrap().new_service(&())
@@ -644,16 +645,19 @@ impl Service for AppChain {
type Error = ();
type Future = FutureResult >,
`
+/// Service factory to convert `Request` to a `ServiceRequest`.
+/// It also executes state factories.
pub struct AppInit