fix conflict between httpservicefactory trait and alias

This commit is contained in:
Rob Ede 2021-11-24 14:18:04 +00:00
parent 10459915d7
commit 966875b349
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
4 changed files with 37 additions and 21 deletions

View File

@ -13,7 +13,8 @@ use crate::{
request::{HttpRequest, HttpRequestPool},
rmap::ResourceMap,
service::{
AppServiceFactory, HttpService, HttpServiceFactory, ServiceRequest, ServiceResponse,
AppServiceFactory, BoxedHttpService, BoxedHttpServiceFactory, ServiceRequest,
ServiceResponse,
},
Error, HttpResponse,
};
@ -36,7 +37,7 @@ where
pub(crate) extensions: RefCell<Option<Extensions>>,
pub(crate) async_data_factories: Rc<[FnDataFactory]>,
pub(crate) services: Rc<RefCell<Vec<Box<dyn AppServiceFactory>>>>,
pub(crate) default: Option<Rc<HttpServiceFactory>>,
pub(crate) default: Option<Rc<BoxedHttpServiceFactory>>,
pub(crate) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
pub(crate) external: RefCell<Vec<ResourceDef>>,
}
@ -227,8 +228,14 @@ where
}
pub struct AppRoutingFactory {
services: Rc<[(ResourceDef, HttpServiceFactory, RefCell<Option<Guards>>)]>,
default: Rc<HttpServiceFactory>,
services: Rc<
[(
ResourceDef,
BoxedHttpServiceFactory,
RefCell<Option<Guards>>,
)],
>,
default: Rc<BoxedHttpServiceFactory>,
}
impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
@ -276,8 +283,8 @@ impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
/// The Actix Web router default entry point.
pub struct AppRouting {
router: Router<HttpService, Guards>,
default: HttpService,
router: Router<BoxedHttpService, Guards>,
default: BoxedHttpService,
}
impl Service<ServiceRequest> for AppRouting {

View File

@ -14,12 +14,15 @@ use futures_util::future::join_all;
use crate::{
data::Data,
dev::{ensure_leading_slash, AppService, HttpServiceFactory, ResourceDef},
dev::{ensure_leading_slash, AppService, ResourceDef},
guard::Guard,
handler::Handler,
responder::Responder,
route::{Route, RouteService},
service::{HttpService, HttpServiceFactory, ServiceRequest, ServiceResponse},
service::{
BoxedHttpService, BoxedHttpServiceFactory, HttpServiceFactory, ServiceRequest,
ServiceResponse,
},
Error, FromRequest, HttpResponse,
};
@ -52,7 +55,7 @@ pub struct Resource<T = ResourceEndpoint> {
routes: Vec<Route>,
app_data: Option<Extensions>,
guards: Vec<Box<dyn Guard>>,
default: HttpServiceFactory,
default: BoxedHttpServiceFactory,
factory_ref: Rc<RefCell<Option<ResourceFactory>>>,
}
@ -418,7 +421,7 @@ where
pub struct ResourceFactory {
routes: Vec<Route>,
default: HttpServiceFactory,
default: BoxedHttpServiceFactory,
}
impl ServiceFactory<ServiceRequest> for ResourceFactory {
@ -450,7 +453,7 @@ impl ServiceFactory<ServiceRequest> for ResourceFactory {
pub struct ResourceService {
routes: Vec<RouteService>,
default: HttpService,
default: BoxedHttpService,
}
impl Service<ServiceRequest> for ResourceService {

View File

@ -12,12 +12,12 @@ use futures_util::future::join_all;
use crate::{
config::ServiceConfig,
data::Data,
dev::{AppService, HttpServiceFactory},
dev::AppService,
guard::Guard,
rmap::ResourceMap,
service::{
AppServiceFactory, HttpService, HttpServiceFactory, ServiceFactoryWrapper,
ServiceRequest, ServiceResponse,
AppServiceFactory, BoxedHttpService, BoxedHttpServiceFactory, HttpServiceFactory,
ServiceFactoryWrapper, ServiceRequest, ServiceResponse,
},
Error, Resource, Route,
};
@ -58,7 +58,7 @@ pub struct Scope<T = ScopeEndpoint> {
app_data: Option<Extensions>,
services: Vec<Box<dyn AppServiceFactory>>,
guards: Vec<Box<dyn Guard>>,
default: Option<Rc<HttpServiceFactory>>,
default: Option<Rc<BoxedHttpServiceFactory>>,
external: Vec<ResourceDef>,
factory_ref: Rc<RefCell<Option<ScopeFactory>>>,
}
@ -470,8 +470,14 @@ where
}
pub struct ScopeFactory {
services: Rc<[(ResourceDef, HttpServiceFactory, RefCell<Option<Guards>>)]>,
default: Rc<HttpServiceFactory>,
services: Rc<
[(
ResourceDef,
BoxedHttpServiceFactory,
RefCell<Option<Guards>>,
)],
>,
default: Rc<BoxedHttpServiceFactory>,
}
impl ServiceFactory<ServiceRequest> for ScopeFactory {
@ -518,8 +524,8 @@ impl ServiceFactory<ServiceRequest> for ScopeFactory {
}
pub struct ScopeService {
router: Router<HttpService, Vec<Box<dyn Guard>>>,
default: HttpService,
router: Router<BoxedHttpService, Vec<Box<dyn Guard>>>,
default: BoxedHttpService,
}
impl Service<ServiceRequest> for ScopeService {

View File

@ -24,8 +24,8 @@ use crate::{
Error, HttpRequest, HttpResponse,
};
pub(crate) type HttpService = BoxService<ServiceRequest, ServiceResponse, Error>;
pub(crate) type HttpServiceFactory =
pub(crate) type BoxedHttpService = BoxService<ServiceRequest, ServiceResponse, Error>;
pub(crate) type BoxedHttpServiceFactory =
BoxServiceFactory<(), ServiceRequest, ServiceResponse, Error, ()>;
pub trait HttpServiceFactory {