mirror of
https://github.com/actix/examples
synced 2024-12-03 18:22:14 +01:00
21 lines
411 B
Rust
21 lines
411 B
Rust
|
extern crate actix;
|
||
|
extern crate actix_web;
|
||
|
|
||
|
use actix_web::{server, App};
|
||
|
|
||
|
mod simple;
|
||
|
|
||
|
fn main() {
|
||
|
let sys = actix::System::new("middleware-example");
|
||
|
|
||
|
let _addr = server::new(|| {
|
||
|
App::new()
|
||
|
.middleware(simple::SayHi)
|
||
|
.resource("/index.html", |r| r.f(|_| "Hello, middleware!"))
|
||
|
}).bind("0.0.0.0:8080")
|
||
|
.unwrap()
|
||
|
.start();
|
||
|
|
||
|
let _ = sys.run();
|
||
|
}
|