mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
upgrade example to actix-web 0.7
This commit is contained in:
@ -4,5 +4,6 @@ version = "0.1.0"
|
||||
authors = ["Gorm Casper <gcasper@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
actix = "0.5"
|
||||
actix-web = "^0.6"
|
||||
actix = "0.7"
|
||||
#actix-web = "^0.7"
|
||||
actix-web = { git = "https://github.com/actix/actix-web.git" }
|
||||
|
@ -7,7 +7,7 @@ pub struct CheckLogin;
|
||||
|
||||
impl<S> Middleware<S> for CheckLogin {
|
||||
// We only need to hook into the `start` for this middleware.
|
||||
fn start(&self, req: &mut HttpRequest<S>) -> Result<Started> {
|
||||
fn start(&self, req: &HttpRequest<S>) -> Result<Started> {
|
||||
let is_logged_in = false; // Change this to see the change in outcome in the browser
|
||||
|
||||
if is_logged_in {
|
||||
|
@ -8,21 +8,17 @@ use actix_web::{HttpRequest, HttpResponse, Result};
|
||||
pub struct SayHi;
|
||||
|
||||
impl<S> Middleware<S> for SayHi {
|
||||
fn start(&self, req: &mut HttpRequest<S>) -> Result<Started> {
|
||||
fn start(&self, req: &HttpRequest<S>) -> Result<Started> {
|
||||
println!("Hi from start. You requested: {}", req.path());
|
||||
Ok(Started::Done)
|
||||
}
|
||||
|
||||
fn response(
|
||||
&self,
|
||||
_req: &mut HttpRequest<S>,
|
||||
resp: HttpResponse,
|
||||
) -> Result<Response> {
|
||||
fn response(&self, _req: &HttpRequest<S>, resp: HttpResponse) -> Result<Response> {
|
||||
println!("Hi from response");
|
||||
Ok(Response::Done(resp))
|
||||
}
|
||||
|
||||
fn finish(&self, _req: &mut HttpRequest<S>, _resp: &HttpResponse) -> Finished {
|
||||
fn finish(&self, _req: &HttpRequest<S>, _resp: &HttpResponse) -> Finished {
|
||||
println!("Hi from finish");
|
||||
Finished::Done
|
||||
}
|
||||
|
Reference in New Issue
Block a user