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:
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user