1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-20 20:55:51 +02:00

revert generic request parameter for service; support ServerConfig as new factory config

This commit is contained in:
Nikolay Kim
2019-03-09 09:49:11 -08:00
parent aadcdaa3d6
commit fde55ffa14
14 changed files with 581 additions and 460 deletions

View File

@@ -52,11 +52,12 @@ where
}
}
}
impl<F, T, R> NewService<(T, HttpRequest)> for Handler<F, T, R>
impl<F, T, R> NewService for Handler<F, T, R>
where
F: Factory<T, R>,
R: Responder + 'static,
{
type Request = (T, HttpRequest);
type Response = ServiceResponse;
type Error = Void;
type InitError = ();
@@ -81,11 +82,12 @@ where
_t: PhantomData<(T, R)>,
}
impl<F, T, R> Service<(T, HttpRequest)> for HandlerService<F, T, R>
impl<F, T, R> Service for HandlerService<F, T, R>
where
F: Factory<T, R>,
R: Responder + 'static,
{
type Request = (T, HttpRequest);
type Response = ServiceResponse;
type Error = Void;
type Future = HandlerServiceResponse<<R::Future as IntoFuture>::Future>;
@@ -182,13 +184,14 @@ where
}
}
}
impl<F, T, R> NewService<(T, HttpRequest)> for AsyncHandler<F, T, R>
impl<F, T, R> NewService for AsyncHandler<F, T, R>
where
F: AsyncFactory<T, R>,
R: IntoFuture,
R::Item: Into<Response>,
R::Error: Into<Error>,
{
type Request = (T, HttpRequest);
type Response = ServiceResponse;
type Error = ();
type InitError = ();
@@ -215,13 +218,14 @@ where
_t: PhantomData<(T, R)>,
}
impl<F, T, R> Service<(T, HttpRequest)> for AsyncHandlerService<F, T, R>
impl<F, T, R> Service for AsyncHandlerService<F, T, R>
where
F: AsyncFactory<T, R>,
R: IntoFuture,
R::Item: Into<Response>,
R::Error: Into<Error>,
{
type Request = (T, HttpRequest);
type Response = ServiceResponse;
type Error = ();
type Future = AsyncHandlerServiceResponse<R::Future>;
@@ -286,7 +290,8 @@ impl<P, T: FromRequest<P>> Extract<P, T> {
}
}
impl<P, T: FromRequest<P>> NewService<ServiceRequest<P>> for Extract<P, T> {
impl<P, T: FromRequest<P>> NewService for Extract<P, T> {
type Request = ServiceRequest<P>;
type Response = (T, HttpRequest);
type Error = (Error, ServiceFromRequest<P>);
type InitError = ();
@@ -306,7 +311,8 @@ pub struct ExtractService<P, T: FromRequest<P>> {
_t: PhantomData<(P, T)>,
}
impl<P, T: FromRequest<P>> Service<ServiceRequest<P>> for ExtractService<P, T> {
impl<P, T: FromRequest<P>> Service for ExtractService<P, T> {
type Request = ServiceRequest<P>;
type Response = (T, HttpRequest);
type Error = (Error, ServiceFromRequest<P>);
type Future = ExtractResponse<P, T>;