1
0
mirror of https://github.com/actix/actix-website synced 2024-11-30 19:14:36 +01:00

Merge pull request #48 from lzxZz/eaxmple-add

handlers.md example code add
This commit is contained in:
Nikolay Kim 2018-10-10 07:42:46 -07:00 committed by GitHub
commit 29977f4930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,6 +77,14 @@ impl<S> Handler<S> for MyHandler {
HttpResponse::Ok().into() 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 Although this handler will work, `self.0` will be different depending on the number of threads and