mirror of https://github.com/fafhrd91/actix-web
rename factory to handler
This commit is contained in:
parent
a59dd6d86e
commit
7fff15ad78
|
@ -15,7 +15,7 @@ use crate::responder::Responder;
|
|||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
|
||||
/// Async handler converter factory
|
||||
pub trait Factory<T, R, O>: Clone + 'static
|
||||
pub trait Handler<T, R, O>: Clone + 'static
|
||||
where
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -23,7 +23,7 @@ where
|
|||
fn call(&self, param: T) -> R;
|
||||
}
|
||||
|
||||
impl<F, R, O> Factory<(), R, O> for F
|
||||
impl<F, R, O> Handler<(), R, O> for F
|
||||
where
|
||||
F: Fn() -> R + Clone + 'static,
|
||||
R: Future<Output = O>,
|
||||
|
@ -38,7 +38,7 @@ where
|
|||
/// Extract arguments from request, run factory function and make response.
|
||||
pub struct HandlerService<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -49,7 +49,7 @@ where
|
|||
|
||||
impl<F, T, R, O> HandlerService<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -64,7 +64,7 @@ where
|
|||
|
||||
impl<F, T, R, O> Clone for HandlerService<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -79,7 +79,7 @@ where
|
|||
|
||||
impl<F, T, R, O> ServiceFactory for HandlerService<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -97,10 +97,10 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// Handler is both it's ServiceFactory and Service Type.
|
||||
// Handler is both it's ServiceHandler and Service Type.
|
||||
impl<F, T, R, O> Service for HandlerService<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -125,7 +125,7 @@ where
|
|||
#[pin_project(project = HandlerProj)]
|
||||
pub enum HandlerServiceFuture<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -137,7 +137,7 @@ where
|
|||
|
||||
impl<F, T, R, O> Future for HandlerServiceFuture<F, T, R, O>
|
||||
where
|
||||
F: Factory<T, R, O>,
|
||||
F: Handler<T, R, O>,
|
||||
T: FromRequest,
|
||||
R: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
@ -181,7 +181,7 @@ where
|
|||
|
||||
/// FromRequest trait impl for tuples
|
||||
macro_rules! factory_tuple ({ $(($n:tt, $T:ident)),+} => {
|
||||
impl<Func, $($T,)+ Res, O> Factory<($($T,)+), Res, O> for Func
|
||||
impl<Func, $($T,)+ Res, O> Handler<($($T,)+), Res, O> for Func
|
||||
where Func: Fn($($T,)+) -> Res + Clone + 'static,
|
||||
Res: Future<Output = O>,
|
||||
O: Responder,
|
||||
|
|
|
@ -121,7 +121,7 @@ pub mod dev {
|
|||
|
||||
pub use crate::config::{AppConfig, AppService};
|
||||
#[doc(hidden)]
|
||||
pub use crate::handler::Factory;
|
||||
pub use crate::handler::Handler;
|
||||
pub use crate::info::ConnectionInfo;
|
||||
pub use crate::rmap::ResourceMap;
|
||||
pub use crate::service::{
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::data::Data;
|
|||
use crate::dev::{insert_slash, AppService, HttpServiceFactory, ResourceDef};
|
||||
use crate::extract::FromRequest;
|
||||
use crate::guard::Guard;
|
||||
use crate::handler::Factory;
|
||||
use crate::handler::Handler;
|
||||
use crate::responder::Responder;
|
||||
use crate::route::{CreateRouteService, Route, RouteService};
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
|
@ -229,7 +229,7 @@ where
|
|||
/// ```
|
||||
pub fn to<F, I, R, U>(mut self, handler: F) -> Self
|
||||
where
|
||||
F: Factory<I, R, U>,
|
||||
F: Handler<I, R, U>,
|
||||
I: FromRequest + 'static,
|
||||
R: Future<Output = U> + 'static,
|
||||
U: Responder + 'static,
|
||||
|
|
|
@ -11,7 +11,7 @@ use futures_util::future::{ready, FutureExt, LocalBoxFuture};
|
|||
|
||||
use crate::extract::FromRequest;
|
||||
use crate::guard::{self, Guard};
|
||||
use crate::handler::{Factory, HandlerService};
|
||||
use crate::handler::{Handler, HandlerService};
|
||||
use crate::responder::Responder;
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
use crate::HttpResponse;
|
||||
|
@ -221,7 +221,7 @@ impl Route {
|
|||
/// ```
|
||||
pub fn to<F, T, R, U>(mut self, handler: F) -> Self
|
||||
where
|
||||
F: Factory<T, R, U>,
|
||||
F: Handler<T, R, U>,
|
||||
T: FromRequest + 'static,
|
||||
R: Future<Output = U> + 'static,
|
||||
U: Responder + 'static,
|
||||
|
|
|
@ -9,7 +9,7 @@ pub use futures_channel::oneshot::Canceled;
|
|||
|
||||
use crate::error::BlockingError;
|
||||
use crate::extract::FromRequest;
|
||||
use crate::handler::Factory;
|
||||
use crate::handler::Handler;
|
||||
use crate::resource::Resource;
|
||||
use crate::responder::Responder;
|
||||
use crate::route::Route;
|
||||
|
@ -246,7 +246,7 @@ pub fn method(method: Method) -> Route {
|
|||
/// ```
|
||||
pub fn to<F, I, R, U>(handler: F) -> Route
|
||||
where
|
||||
F: Factory<I, R, U>,
|
||||
F: Handler<I, R, U>,
|
||||
I: FromRequest + 'static,
|
||||
R: Future<Output = U> + 'static,
|
||||
U: Responder + 'static,
|
||||
|
|
Loading…
Reference in New Issue