mirror of https://github.com/fafhrd91/actix-web
fix conflict between httpservicefactory trait and alias
This commit is contained in:
parent
10459915d7
commit
966875b349
|
@ -13,7 +13,8 @@ use crate::{
|
||||||
request::{HttpRequest, HttpRequestPool},
|
request::{HttpRequest, HttpRequestPool},
|
||||||
rmap::ResourceMap,
|
rmap::ResourceMap,
|
||||||
service::{
|
service::{
|
||||||
AppServiceFactory, HttpService, HttpServiceFactory, ServiceRequest, ServiceResponse,
|
AppServiceFactory, BoxedHttpService, BoxedHttpServiceFactory, ServiceRequest,
|
||||||
|
ServiceResponse,
|
||||||
},
|
},
|
||||||
Error, HttpResponse,
|
Error, HttpResponse,
|
||||||
};
|
};
|
||||||
|
@ -36,7 +37,7 @@ where
|
||||||
pub(crate) extensions: RefCell<Option<Extensions>>,
|
pub(crate) extensions: RefCell<Option<Extensions>>,
|
||||||
pub(crate) async_data_factories: Rc<[FnDataFactory]>,
|
pub(crate) async_data_factories: Rc<[FnDataFactory]>,
|
||||||
pub(crate) services: Rc<RefCell<Vec<Box<dyn AppServiceFactory>>>>,
|
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) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
|
||||||
pub(crate) external: RefCell<Vec<ResourceDef>>,
|
pub(crate) external: RefCell<Vec<ResourceDef>>,
|
||||||
}
|
}
|
||||||
|
@ -227,8 +228,14 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AppRoutingFactory {
|
pub struct AppRoutingFactory {
|
||||||
services: Rc<[(ResourceDef, HttpServiceFactory, RefCell<Option<Guards>>)]>,
|
services: Rc<
|
||||||
default: Rc<HttpServiceFactory>,
|
[(
|
||||||
|
ResourceDef,
|
||||||
|
BoxedHttpServiceFactory,
|
||||||
|
RefCell<Option<Guards>>,
|
||||||
|
)],
|
||||||
|
>,
|
||||||
|
default: Rc<BoxedHttpServiceFactory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
|
impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
|
||||||
|
@ -276,8 +283,8 @@ impl ServiceFactory<ServiceRequest> for AppRoutingFactory {
|
||||||
|
|
||||||
/// The Actix Web router default entry point.
|
/// The Actix Web router default entry point.
|
||||||
pub struct AppRouting {
|
pub struct AppRouting {
|
||||||
router: Router<HttpService, Guards>,
|
router: Router<BoxedHttpService, Guards>,
|
||||||
default: HttpService,
|
default: BoxedHttpService,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service<ServiceRequest> for AppRouting {
|
impl Service<ServiceRequest> for AppRouting {
|
||||||
|
|
|
@ -14,12 +14,15 @@ use futures_util::future::join_all;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::Data,
|
data::Data,
|
||||||
dev::{ensure_leading_slash, AppService, HttpServiceFactory, ResourceDef},
|
dev::{ensure_leading_slash, AppService, ResourceDef},
|
||||||
guard::Guard,
|
guard::Guard,
|
||||||
handler::Handler,
|
handler::Handler,
|
||||||
responder::Responder,
|
responder::Responder,
|
||||||
route::{Route, RouteService},
|
route::{Route, RouteService},
|
||||||
service::{HttpService, HttpServiceFactory, ServiceRequest, ServiceResponse},
|
service::{
|
||||||
|
BoxedHttpService, BoxedHttpServiceFactory, HttpServiceFactory, ServiceRequest,
|
||||||
|
ServiceResponse,
|
||||||
|
},
|
||||||
Error, FromRequest, HttpResponse,
|
Error, FromRequest, HttpResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ pub struct Resource<T = ResourceEndpoint> {
|
||||||
routes: Vec<Route>,
|
routes: Vec<Route>,
|
||||||
app_data: Option<Extensions>,
|
app_data: Option<Extensions>,
|
||||||
guards: Vec<Box<dyn Guard>>,
|
guards: Vec<Box<dyn Guard>>,
|
||||||
default: HttpServiceFactory,
|
default: BoxedHttpServiceFactory,
|
||||||
factory_ref: Rc<RefCell<Option<ResourceFactory>>>,
|
factory_ref: Rc<RefCell<Option<ResourceFactory>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +421,7 @@ where
|
||||||
|
|
||||||
pub struct ResourceFactory {
|
pub struct ResourceFactory {
|
||||||
routes: Vec<Route>,
|
routes: Vec<Route>,
|
||||||
default: HttpServiceFactory,
|
default: BoxedHttpServiceFactory,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServiceFactory<ServiceRequest> for ResourceFactory {
|
impl ServiceFactory<ServiceRequest> for ResourceFactory {
|
||||||
|
@ -450,7 +453,7 @@ impl ServiceFactory<ServiceRequest> for ResourceFactory {
|
||||||
|
|
||||||
pub struct ResourceService {
|
pub struct ResourceService {
|
||||||
routes: Vec<RouteService>,
|
routes: Vec<RouteService>,
|
||||||
default: HttpService,
|
default: BoxedHttpService,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service<ServiceRequest> for ResourceService {
|
impl Service<ServiceRequest> for ResourceService {
|
||||||
|
|
22
src/scope.rs
22
src/scope.rs
|
@ -12,12 +12,12 @@ use futures_util::future::join_all;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::ServiceConfig,
|
config::ServiceConfig,
|
||||||
data::Data,
|
data::Data,
|
||||||
dev::{AppService, HttpServiceFactory},
|
dev::AppService,
|
||||||
guard::Guard,
|
guard::Guard,
|
||||||
rmap::ResourceMap,
|
rmap::ResourceMap,
|
||||||
service::{
|
service::{
|
||||||
AppServiceFactory, HttpService, HttpServiceFactory, ServiceFactoryWrapper,
|
AppServiceFactory, BoxedHttpService, BoxedHttpServiceFactory, HttpServiceFactory,
|
||||||
ServiceRequest, ServiceResponse,
|
ServiceFactoryWrapper, ServiceRequest, ServiceResponse,
|
||||||
},
|
},
|
||||||
Error, Resource, Route,
|
Error, Resource, Route,
|
||||||
};
|
};
|
||||||
|
@ -58,7 +58,7 @@ pub struct Scope<T = ScopeEndpoint> {
|
||||||
app_data: Option<Extensions>,
|
app_data: Option<Extensions>,
|
||||||
services: Vec<Box<dyn AppServiceFactory>>,
|
services: Vec<Box<dyn AppServiceFactory>>,
|
||||||
guards: Vec<Box<dyn Guard>>,
|
guards: Vec<Box<dyn Guard>>,
|
||||||
default: Option<Rc<HttpServiceFactory>>,
|
default: Option<Rc<BoxedHttpServiceFactory>>,
|
||||||
external: Vec<ResourceDef>,
|
external: Vec<ResourceDef>,
|
||||||
factory_ref: Rc<RefCell<Option<ScopeFactory>>>,
|
factory_ref: Rc<RefCell<Option<ScopeFactory>>>,
|
||||||
}
|
}
|
||||||
|
@ -470,8 +470,14 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ScopeFactory {
|
pub struct ScopeFactory {
|
||||||
services: Rc<[(ResourceDef, HttpServiceFactory, RefCell<Option<Guards>>)]>,
|
services: Rc<
|
||||||
default: Rc<HttpServiceFactory>,
|
[(
|
||||||
|
ResourceDef,
|
||||||
|
BoxedHttpServiceFactory,
|
||||||
|
RefCell<Option<Guards>>,
|
||||||
|
)],
|
||||||
|
>,
|
||||||
|
default: Rc<BoxedHttpServiceFactory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServiceFactory<ServiceRequest> for ScopeFactory {
|
impl ServiceFactory<ServiceRequest> for ScopeFactory {
|
||||||
|
@ -518,8 +524,8 @@ impl ServiceFactory<ServiceRequest> for ScopeFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ScopeService {
|
pub struct ScopeService {
|
||||||
router: Router<HttpService, Vec<Box<dyn Guard>>>,
|
router: Router<BoxedHttpService, Vec<Box<dyn Guard>>>,
|
||||||
default: HttpService,
|
default: BoxedHttpService,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service<ServiceRequest> for ScopeService {
|
impl Service<ServiceRequest> for ScopeService {
|
||||||
|
|
|
@ -24,8 +24,8 @@ use crate::{
|
||||||
Error, HttpRequest, HttpResponse,
|
Error, HttpRequest, HttpResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) type HttpService = BoxService<ServiceRequest, ServiceResponse, Error>;
|
pub(crate) type BoxedHttpService = BoxService<ServiceRequest, ServiceResponse, Error>;
|
||||||
pub(crate) type HttpServiceFactory =
|
pub(crate) type BoxedHttpServiceFactory =
|
||||||
BoxServiceFactory<(), ServiceRequest, ServiceResponse, Error, ()>;
|
BoxServiceFactory<(), ServiceRequest, ServiceResponse, Error, ()>;
|
||||||
|
|
||||||
pub trait HttpServiceFactory {
|
pub trait HttpServiceFactory {
|
||||||
|
|
Loading…
Reference in New Issue