mirror of
https://github.com/actix/actix-web.git
synced 2024-12-28 02:50:39 +00:00
remove generic body type in App. (#2493)
This commit is contained in:
parent
9587261c20
commit
6460e67f84
1 changed files with 25 additions and 28 deletions
53
src/app.rs
53
src/app.rs
|
@ -1,9 +1,6 @@
|
|||
use std::{cell::RefCell, fmt, future::Future, marker::PhantomData, rc::Rc};
|
||||
use std::{cell::RefCell, fmt, future::Future, rc::Rc};
|
||||
|
||||
use actix_http::{
|
||||
body::{BoxBody, MessageBody},
|
||||
Extensions, Request,
|
||||
};
|
||||
use actix_http::{body::MessageBody, Extensions, Request};
|
||||
use actix_service::{
|
||||
apply, apply_fn_factory, boxed, IntoServiceFactory, ServiceFactory, ServiceFactoryExt,
|
||||
Transform,
|
||||
|
@ -26,7 +23,7 @@ use crate::{
|
|||
|
||||
/// Application builder - structure that follows the builder pattern
|
||||
/// for building application instances.
|
||||
pub struct App<T, B> {
|
||||
pub struct App<T> {
|
||||
endpoint: T,
|
||||
services: Vec<Box<dyn AppServiceFactory>>,
|
||||
default: Option<Rc<BoxedHttpServiceFactory>>,
|
||||
|
@ -34,10 +31,9 @@ pub struct App<T, B> {
|
|||
data_factories: Vec<FnDataFactory>,
|
||||
external: Vec<ResourceDef>,
|
||||
extensions: Extensions,
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl App<AppEntry, BoxBody> {
|
||||
impl App<AppEntry> {
|
||||
/// Create application builder. Application can be configured with a builder-like pattern.
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
|
@ -51,22 +47,11 @@ impl App<AppEntry, BoxBody> {
|
|||
factory_ref,
|
||||
external: Vec::new(),
|
||||
extensions: Extensions::new(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> App<T, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
T: ServiceFactory<
|
||||
ServiceRequest,
|
||||
Config = (),
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
{
|
||||
impl<T> App<T> {
|
||||
/// Set application (root level) data.
|
||||
///
|
||||
/// Application data stored with `App::app_data()` method is available through the
|
||||
|
@ -365,7 +350,7 @@ where
|
|||
/// .route("/index.html", web::get().to(index));
|
||||
/// }
|
||||
/// ```
|
||||
pub fn wrap<M, B1>(
|
||||
pub fn wrap<M, B, B1>(
|
||||
self,
|
||||
mw: M,
|
||||
) -> App<
|
||||
|
@ -376,9 +361,16 @@ where
|
|||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
B1,
|
||||
>
|
||||
where
|
||||
T: ServiceFactory<
|
||||
ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
Config = (),
|
||||
InitError = (),
|
||||
>,
|
||||
B: MessageBody,
|
||||
M: Transform<
|
||||
T::Service,
|
||||
ServiceRequest,
|
||||
|
@ -396,7 +388,6 @@ where
|
|||
factory_ref: self.factory_ref,
|
||||
external: self.external,
|
||||
extensions: self.extensions,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +422,7 @@ where
|
|||
/// .route("/index.html", web::get().to(index));
|
||||
/// }
|
||||
/// ```
|
||||
pub fn wrap_fn<B1, F, R>(
|
||||
pub fn wrap_fn<F, R, B, B1>(
|
||||
self,
|
||||
mw: F,
|
||||
) -> App<
|
||||
|
@ -442,12 +433,19 @@ where
|
|||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
B1,
|
||||
>
|
||||
where
|
||||
B1: MessageBody,
|
||||
T: ServiceFactory<
|
||||
ServiceRequest,
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
Config = (),
|
||||
InitError = (),
|
||||
>,
|
||||
B: MessageBody,
|
||||
F: Fn(ServiceRequest, &T::Service) -> R + Clone,
|
||||
R: Future<Output = Result<ServiceResponse<B1>, Error>>,
|
||||
B1: MessageBody,
|
||||
{
|
||||
App {
|
||||
endpoint: apply_fn_factory(self.endpoint, mw),
|
||||
|
@ -457,12 +455,11 @@ where
|
|||
factory_ref: self.factory_ref,
|
||||
external: self.external,
|
||||
extensions: self.extensions,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> IntoServiceFactory<AppInit<T, B>, Request> for App<T, B>
|
||||
impl<T, B> IntoServiceFactory<AppInit<T, B>, Request> for App<T>
|
||||
where
|
||||
B: MessageBody,
|
||||
T: ServiceFactory<
|
||||
|
|
Loading…
Reference in a new issue