1
0
mirror of https://github.com/actix/actix-website synced 2025-02-20 03:14:22 +01:00

fix application examples

This commit is contained in:
Nikolay Kim 2018-05-24 09:31:40 -07:00
parent 20ea20ae31
commit ec11bf0db3
2 changed files with 27 additions and 27 deletions

View File

@ -5,7 +5,7 @@ use actix_web::{http::Method, server, App, HttpRequest, HttpResponse, Responder}
mod state; mod state;
fn make_app() { fn make_app() {
// <make_app> // <make_app>
fn index(req: HttpRequest) -> impl Responder { fn index(req: HttpRequest) -> impl Responder {
"Hello world!" "Hello world!"
} }
@ -19,7 +19,7 @@ fn make_app() {
} }
fn run_server() { fn run_server() {
// <run_server> // <run_server>
let server = server::new(|| { let server = server::new(|| {
vec![ vec![
App::new() App::new()
@ -31,7 +31,7 @@ fn run_server() {
App::new().resource("/", |r| r.f(|r| HttpResponse::Ok())), App::new().resource("/", |r| r.f(|r| HttpResponse::Ok())),
] ]
}); });
// </run_server> // </run_server>
} }
fn main() { fn main() {

View File

@ -16,8 +16,8 @@ fn index(req: HttpRequest<AppState>) -> String {
// </setup> // </setup>
fn make_app() { fn make_app() {
// <make_app> // <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)) .resource("/", |r| r.method(http::Method::GET).f(index))
.finish() .finish()
// </make_app> // </make_app>
@ -29,11 +29,11 @@ use std::thread;
fn combine() { fn combine() {
thread::spawn(|| { thread::spawn(|| {
// <combine> // <combine>
struct State1; struct State1;
struct State2; struct State2;
fn main() { fn main() {
server::new(|| { server::new(|| {
vec![ vec![
App::with_state(State1) App::with_state(State1)
@ -48,8 +48,8 @@ fn combine() {
}).bind("127.0.0.1:8080") }).bind("127.0.0.1:8080")
.unwrap() .unwrap()
.run() .run()
} }
// </combine> // </combine>
}); });
} }