From ec11bf0db35fb73b4352d185ead3bd5c3fc52143 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 24 May 2018 09:31:40 -0700 Subject: [PATCH] fix application examples --- examples/application/src/main.rs | 12 ++++----- examples/application/src/state.rs | 42 +++++++++++++++---------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/application/src/main.rs b/examples/application/src/main.rs index 17c9235..321b0bc 100644 --- a/examples/application/src/main.rs +++ b/examples/application/src/main.rs @@ -5,21 +5,21 @@ use actix_web::{http::Method, server, App, HttpRequest, HttpResponse, Responder} mod state; fn make_app() { - // +// fn index(req: HttpRequest) -> impl Responder { "Hello world!" } let app = App::new() - .prefix("/app") - .resource("/index.html", |r| r.method(Method::GET).f(index)) - .finish() + .prefix("/app") + .resource("/index.html", |r| r.method(Method::GET).f(index)) + .finish() // ; } fn run_server() { - // +// let server = server::new(|| { vec![ App::new() @@ -31,7 +31,7 @@ fn run_server() { App::new().resource("/", |r| r.f(|r| HttpResponse::Ok())), ] }); - // +// } fn main() { diff --git a/examples/application/src/state.rs b/examples/application/src/state.rs index 5f89508..e8c81a8 100644 --- a/examples/application/src/state.rs +++ b/examples/application/src/state.rs @@ -16,8 +16,8 @@ fn index(req: HttpRequest) -> String { // fn make_app() { - // - App::with_state(AppState { counter: Cell::new(0) }) +// +App::with_state(AppState { counter: Cell::new(0) }) .resource("/", |r| r.method(http::Method::GET).f(index)) .finish() // @@ -29,27 +29,27 @@ use std::thread; fn combine() { thread::spawn(|| { - // - struct State1; - struct State2; +// +struct State1; +struct State2; - fn main() { - server::new(|| { - vec![ - App::with_state(State1) - .prefix("/app1") - .resource("/", |r| r.f(|r| HttpResponse::Ok())) - .boxed(), - App::with_state(State2) - .prefix("/app2") - .resource("/", |r| r.f(|r| HttpResponse::Ok())) - .boxed(), +fn main() { + server::new(|| { + vec![ + App::with_state(State1) + .prefix("/app1") + .resource("/", |r| r.f(|r| HttpResponse::Ok())) + .boxed(), + App::with_state(State2) + .prefix("/app2") + .resource("/", |r| r.f(|r| HttpResponse::Ok())) + .boxed(), ] - }).bind("127.0.0.1:8080") - .unwrap() - .run() - } - // + }).bind("127.0.0.1:8080") + .unwrap() + .run() +} +// }); }