1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

renamed Route::handler to Route::f, added Route::h to register Handler

This commit is contained in:
Nikolay Kim
2017-12-04 14:07:53 -08:00
parent 03f7d95d88
commit f5d6179a34
19 changed files with 79 additions and 40 deletions

View File

@ -69,11 +69,11 @@ fn main() {
// register simple handle r, handle all methods
.handler("/index.html", index)
// with path parameters
.resource("/user/{name}/", |r| r.route().method(Method::GET).handler(with_param))
.resource("/user/{name}/", |r| r.route().method(Method::GET).f(with_param))
// async handler
.resource("/async/{name}", |r| r.route().method(Method::GET).async(index_async))
// redirect
.resource("/", |r| r.route().method(Method::GET).handler(|req| {
.resource("/", |r| r.route().method(Method::GET).f(|req| {
println!("{:?}", req);
httpcodes::HTTPFound

View File

@ -65,8 +65,9 @@ fn main() {
.middleware(middlewares::Logger::default())
// websocket route
.resource(
"/ws/", |r| r.route().method(Method::GET)
.handler(|req| ws::start(req, MyWebSocket{counter: 0})))
"/ws/", |r| r.route()
.method(Method::GET)
.f(|req| ws::start(req, MyWebSocket{counter: 0})))
// register simple handler, handle all methods
.handler("/", index))
.serve::<_, ()>("127.0.0.1:8080").unwrap();

View File

@ -65,7 +65,7 @@ fn main() {
// enable logger
.middleware(middlewares::Logger::default())
// websocket route
.resource("/ws/", |r| r.route().method(Method::GET).handler(ws_index))
.resource("/ws/", |r| r.route().method(Method::GET).f(ws_index))
// static files
.route("/", fs::StaticFiles::new("examples/static/", true)))
// start http server on 127.0.0.1:8080