1
0
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:
Nikolay Kim
2018-07-16 12:36:53 +06:00
parent 0b52c7850e
commit 2cc1b23761
57 changed files with 913 additions and 693 deletions

View File

@ -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" }

View File

@ -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 {

View File

@ -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
}