mirror of
https://github.com/actix/actix-website
synced 2024-11-23 16:31:08 +01:00
Merge pull request #48 from lzxZz/eaxmple-add
handlers.md example code add
This commit is contained in:
commit
29977f4930
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user