From 8f30db92558bab2ef46e89cdae7dd9b9e01a42b2 Mon Sep 17 00:00:00 2001 From: lzxZz <616281384@qq.com> Date: Sun, 7 Oct 2018 16:46:13 +0800 Subject: [PATCH] handlers.md example code add --- content/docs/handlers.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/content/docs/handlers.md b/content/docs/handlers.md index 386f8c1..975d7d2 100644 --- a/content/docs/handlers.md +++ b/content/docs/handlers.md @@ -77,6 +77,14 @@ impl Handler 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