1
0
mirror of https://github.com/actix/examples synced 2024-12-01 01:24:35 +01:00
examples/middleware/src/main.rs
2018-07-09 21:36:03 +02:00

30 lines
727 B
Rust

extern crate actix;
extern crate actix_web;
use actix_web::{server, App};
#[allow(dead_code)]
mod redirect;
#[allow(dead_code)]
mod simple;
fn main() {
let sys = actix::System::new("middleware-example");
let _addr = server::new(|| {
App::new()
.middleware(simple::SayHi)
// .middleware(redirect::CheckLogin)
.resource("/login", |r| {
r.f(|_| "You are on /login. Go to src/redirect.rs to change this behavior.")
})
.resource("/", |r| {
r.f(|_| "Hello, middleware! Check the console where the server is run.")
})
}).bind("127.0.0.1:8080")
.unwrap()
.start();
let _ = sys.run();
}