mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-27 10:39:03 +02:00
update service factory config
This commit is contained in:
@ -66,7 +66,7 @@ where
|
||||
type Service = AppInitService<T::Service, B>;
|
||||
type Future = AppInitResult<T, B>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
// update resource default service
|
||||
let default = self.default.clone().unwrap_or_else(|| {
|
||||
Rc::new(boxed::factory(service_fn(|req: ServiceRequest| {
|
||||
@ -115,7 +115,7 @@ where
|
||||
|
||||
AppInitResult {
|
||||
endpoint: None,
|
||||
endpoint_fut: self.endpoint.new_service(&()),
|
||||
endpoint_fut: self.endpoint.new_service(()),
|
||||
data: self.data.clone(),
|
||||
data_factories: Vec::new(),
|
||||
data_factories_fut: self.data_factories.iter().map(|f| f()).collect(),
|
||||
@ -273,7 +273,7 @@ impl ServiceFactory for AppRoutingFactory {
|
||||
type Service = AppRouting;
|
||||
type Future = AppRoutingFactoryResponse;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
AppRoutingFactoryResponse {
|
||||
fut: self
|
||||
.services
|
||||
@ -282,12 +282,12 @@ impl ServiceFactory for AppRoutingFactory {
|
||||
CreateAppRoutingItem::Future(
|
||||
Some(path.clone()),
|
||||
guards.borrow_mut().take(),
|
||||
service.new_service(&()).boxed_local(),
|
||||
service.new_service(()).boxed_local(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
default: None,
|
||||
default_fut: Some(self.default.new_service(&())),
|
||||
default_fut: Some(self.default.new_service(())),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -432,8 +432,8 @@ impl ServiceFactory for AppEntry {
|
||||
type Service = AppRouting;
|
||||
type Future = AppRoutingFactoryResponse;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
self.factory.borrow_mut().as_mut().unwrap().new_service(&())
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
self.factory.borrow_mut().as_mut().unwrap().new_service(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ where
|
||||
type Service = ExtractService<T, S>;
|
||||
type Future = Ready<Result<Self::Service, ()>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
ok(ExtractService {
|
||||
_t: PhantomData,
|
||||
service: self.service.clone(),
|
||||
|
@ -435,9 +435,9 @@ impl ServiceFactory for ResourceFactory {
|
||||
type Service = ResourceService;
|
||||
type Future = CreateResourceService;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
let default_fut = if let Some(ref default) = *self.default.borrow() {
|
||||
Some(default.new_service(&()))
|
||||
Some(default.new_service(()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -446,7 +446,7 @@ impl ServiceFactory for ResourceFactory {
|
||||
fut: self
|
||||
.routes
|
||||
.iter()
|
||||
.map(|route| CreateRouteServiceItem::Future(route.new_service(&())))
|
||||
.map(|route| CreateRouteServiceItem::Future(route.new_service(())))
|
||||
.collect(),
|
||||
data: self.data.clone(),
|
||||
default: None,
|
||||
@ -575,8 +575,8 @@ impl ServiceFactory for ResourceEndpoint {
|
||||
type Service = ResourceService;
|
||||
type Future = CreateResourceService;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
self.factory.borrow_mut().as_mut().unwrap().new_service(&())
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
self.factory.borrow_mut().as_mut().unwrap().new_service(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,9 +69,9 @@ impl ServiceFactory for Route {
|
||||
type Service = RouteService;
|
||||
type Future = CreateRouteService;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
CreateRouteService {
|
||||
fut: self.service.new_service(&()),
|
||||
fut: self.service.new_service(()),
|
||||
guards: self.guards.clone(),
|
||||
}
|
||||
}
|
||||
@ -280,9 +280,9 @@ where
|
||||
type Service = BoxedRouteService<ServiceRequest, Self::Response>;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
self.service
|
||||
.new_service(&())
|
||||
.new_service(())
|
||||
.map(|result| match result {
|
||||
Ok(service) => {
|
||||
let service: BoxedRouteService<_, _> =
|
||||
|
10
src/scope.rs
10
src/scope.rs
@ -488,9 +488,9 @@ impl ServiceFactory for ScopeFactory {
|
||||
type Service = ScopeService;
|
||||
type Future = ScopeFactoryResponse;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
let default_fut = if let Some(ref default) = *self.default.borrow() {
|
||||
Some(default.new_service(&()))
|
||||
Some(default.new_service(()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -503,7 +503,7 @@ impl ServiceFactory for ScopeFactory {
|
||||
CreateScopeServiceItem::Future(
|
||||
Some(path.clone()),
|
||||
guards.borrow_mut().take(),
|
||||
service.new_service(&()),
|
||||
service.new_service(()),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
@ -656,8 +656,8 @@ impl ServiceFactory for ScopeEndpoint {
|
||||
type Service = ScopeService;
|
||||
type Future = ScopeFactoryResponse;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
self.factory.borrow_mut().as_mut().unwrap().new_service(&())
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
self.factory.borrow_mut().as_mut().unwrap().new_service(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ where
|
||||
S::InitError: std::fmt::Debug,
|
||||
{
|
||||
let srv = app.into_factory();
|
||||
srv.new_service(&()).await.unwrap()
|
||||
srv.new_service(()).await.unwrap()
|
||||
}
|
||||
|
||||
/// Calls service and waits for response future completion.
|
||||
|
Reference in New Issue
Block a user