1
0
mirror of https://github.com/actix/actix-website synced 2025-02-02 04:09:06 +01:00

handlers.md example code add

This commit is contained in:
lzxZz 2018-10-07 16:46:13 +08:00
parent f420916025
commit 8f30db9255

View File

@ -77,6 +77,14 @@ impl<S> Handler<S> for MyHandler {
HttpResponse::Ok().into()
}
}
fn main(){
server::new(|| App::new()
.resource("/", |r| r.h(MyHandler(Cell::new(0))))) //use r.h() to bind handler, not the r.f()
.bind("127.0.0.1:8080")
.unwrap()
.run();
}
```
Although this handler will work, `self.0` will be different depending on the number of threads and