1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

upgrade to alpha.6

This commit is contained in:
Nikolay Kim
2019-04-14 10:34:41 -07:00
parent 8fb2bf6869
commit 09b0188ff9
13 changed files with 93 additions and 117 deletions

View File

@ -6,12 +6,12 @@ use futures::Poll;
pub struct CheckLogin;
impl<S, P, B> Transform<S> for CheckLogin
impl<S, B> Transform<S> for CheckLogin
where
S: Service<Request = ServiceRequest<P>, Response = ServiceResponse<B>>,
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>>,
S::Future: 'static,
{
type Request = ServiceRequest<P>;
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = S::Error;
type InitError = ();
@ -26,12 +26,12 @@ pub struct CheckLoginMiddleware<S> {
service: S,
}
impl<S, P, B> Service for CheckLoginMiddleware<S>
impl<S, B> Service for CheckLoginMiddleware<S>
where
S: Service<Request = ServiceRequest<P>, Response = ServiceResponse<B>>,
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>>,
S::Future: 'static,
{
type Request = ServiceRequest<P>;
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = S::Error;
type Future = Either<S::Future, FutureResult<Self::Response, Self::Error>>;
@ -40,7 +40,7 @@ where
self.service.poll_ready()
}
fn call(&mut self, req: ServiceRequest<P>) -> Self::Future {
fn call(&mut self, req: ServiceRequest) -> Self::Future {
// We only need to hook into the `start` for this middleware.
let is_logged_in = false; // Change this to see the change in outcome in the browser

View File

@ -11,16 +11,15 @@ pub struct SayHi;
// Middleware factory is `Transform` trait from actix-service crate
// `S` - type of the next service
// `P` - type of request's payload
// `B` - type of response's body
impl<S, P, B> Transform<S> for SayHi
impl<S, B> Transform<S> for SayHi
where
S: Service<Request = ServiceRequest<P>, Response = ServiceResponse<B>>,
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>>,
S::Future: 'static,
S::Error: 'static,
B: 'static,
{
type Request = ServiceRequest<P>;
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = S::Error;
type InitError = ();
@ -36,14 +35,14 @@ pub struct SayHiMiddleware<S> {
service: S,
}
impl<S, P, B> Service for SayHiMiddleware<S>
impl<S, B> Service for SayHiMiddleware<S>
where
S: Service<Request = ServiceRequest<P>, Response = ServiceResponse<B>>,
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>>,
S::Future: 'static,
S::Error: 'static,
B: 'static,
{
type Request = ServiceRequest<P>;
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = S::Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
@ -52,7 +51,7 @@ where
self.service.poll_ready()
}
fn call(&mut self, req: ServiceRequest<P>) -> Self::Future {
fn call(&mut self, req: ServiceRequest) -> Self::Future {
println!("Hi from start. You requested: {}", req.path());
Box::new(self.service.call(req).and_then(|res| {