mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
update service factory config
This commit is contained in:
parent
f4c01384ec
commit
068f047dd5
@ -139,4 +139,4 @@ actix-server = { git = "https://github.com/actix/actix-net.git" }
|
||||
actix-service = { git = "https://github.com/actix/actix-net.git" }
|
||||
actix-testing = { git = "https://github.com/actix/actix-net.git" }
|
||||
actix-tls = { git = "https://github.com/actix/actix-net.git" }
|
||||
actix-utils = { git = "https://github.com/actix/actix-net.git" }
|
||||
actix-utils = { git = "https://github.com/actix/actix-net.git" }
|
||||
|
@ -415,7 +415,7 @@ impl ServiceFactory for Files {
|
||||
type InitError = ();
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
let mut srv = FilesService {
|
||||
directory: self.directory.clone(),
|
||||
index: self.index.clone(),
|
||||
@ -430,7 +430,7 @@ impl ServiceFactory for Files {
|
||||
|
||||
if let Some(ref default) = *self.default.borrow() {
|
||||
default
|
||||
.new_service(&())
|
||||
.new_service(())
|
||||
.map(move |result| match result {
|
||||
Ok(default) => {
|
||||
srv.default = Some(default);
|
||||
@ -1262,7 +1262,7 @@ mod tests {
|
||||
.default_handler(|req: ServiceRequest| {
|
||||
ok(req.into_response(HttpResponse::Ok().body("default content")))
|
||||
})
|
||||
.new_service(&())
|
||||
.new_service(())
|
||||
.await
|
||||
.unwrap();
|
||||
let req = TestRequest::with_uri("/missing").to_srv_request();
|
||||
|
@ -104,7 +104,7 @@ where
|
||||
type Service = FramedAppService<T, S>;
|
||||
type Future = CreateService<T, S>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
CreateService {
|
||||
fut: self
|
||||
.services
|
||||
@ -112,7 +112,7 @@ where
|
||||
.map(|(path, service)| {
|
||||
CreateServiceItem::Future(
|
||||
Some(path.clone()),
|
||||
service.new_service(&()),
|
||||
service.new_service(()),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
|
@ -56,8 +56,8 @@ where
|
||||
type Service = BoxedHttpService<T::Request>;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Service, ()>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
let fut = self.0.new_service(&());
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
let fut = self.0.new_service(());
|
||||
|
||||
async move {
|
||||
fut.await.map_err(|_| ()).map(|service| {
|
||||
|
@ -113,7 +113,7 @@ where
|
||||
type Service = FramedRouteService<Io, S, F, R, E>;
|
||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
ok(FramedRouteService {
|
||||
handler: self.handler.clone(),
|
||||
methods: self.methods.clone(),
|
||||
|
@ -33,7 +33,7 @@ impl<T, C> ServiceFactory for VerifyWebSockets<T, C> {
|
||||
type Service = VerifyWebSockets<T, C>;
|
||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &C) -> Self::Future {
|
||||
fn new_service(&self, _: C) -> Self::Future {
|
||||
ok(VerifyWebSockets { _t: PhantomData })
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ where
|
||||
type Service = SendError<T, R, E, C>;
|
||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &C) -> Self::Future {
|
||||
fn new_service(&self, _: C) -> Self::Future {
|
||||
ok(SendError(PhantomData))
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ impl ServiceFactory for ExpectHandler {
|
||||
type InitError = Error;
|
||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
ok(ExpectHandler)
|
||||
}
|
||||
}
|
||||
|
@ -217,11 +217,11 @@ where
|
||||
type Service = H1ServiceHandler<T, S::Service, B, X::Service, U::Service>;
|
||||
type Future = H1ServiceResponse<T, S, B, X, U>;
|
||||
|
||||
fn new_service(&self, cfg: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
H1ServiceResponse {
|
||||
fut: self.srv.new_service(cfg),
|
||||
fut_ex: Some(self.expect.new_service(cfg)),
|
||||
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(cfg)),
|
||||
fut: self.srv.new_service(()),
|
||||
fut_ex: Some(self.expect.new_service(())),
|
||||
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
|
||||
expect: None,
|
||||
upgrade: None,
|
||||
on_connect: self.on_connect.clone(),
|
||||
@ -450,7 +450,7 @@ where
|
||||
type Service = OneRequestService<T>;
|
||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
ok(OneRequestService {
|
||||
_t: PhantomData,
|
||||
config: self.config.clone(),
|
||||
|
@ -20,7 +20,7 @@ impl<T> ServiceFactory for UpgradeHandler<T> {
|
||||
type InitError = Error;
|
||||
type Future = Ready<Result<Self::Service, Self::InitError>>;
|
||||
|
||||
fn new_service(&self, _: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
@ -160,9 +160,9 @@ where
|
||||
type Service = H2ServiceHandler<T, S::Service, B>;
|
||||
type Future = H2ServiceResponse<T, S, B>;
|
||||
|
||||
fn new_service(&self, cfg: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
H2ServiceResponse {
|
||||
fut: self.srv.new_service(cfg),
|
||||
fut: self.srv.new_service(()),
|
||||
cfg: Some(self.cfg.clone()),
|
||||
on_connect: self.on_connect.clone(),
|
||||
_t: PhantomData,
|
||||
|
@ -282,11 +282,11 @@ where
|
||||
type Service = HttpServiceHandler<T, S::Service, B, X::Service, U::Service>;
|
||||
type Future = HttpServiceResponse<T, S, B, X, U>;
|
||||
|
||||
fn new_service(&self, cfg: &()) -> Self::Future {
|
||||
fn new_service(&self, _: ()) -> Self::Future {
|
||||
HttpServiceResponse {
|
||||
fut: self.srv.new_service(cfg),
|
||||
fut_ex: Some(self.expect.new_service(cfg)),
|
||||
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(cfg)),
|
||||
fut: self.srv.new_service(()),
|
||||
fut_ex: Some(self.expect.new_service(())),
|
||||
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
|
||||
expect: None,
|
||||
upgrade: None,
|
||||
on_connect: self.on_connect.clone(),
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user