1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-28 01:52:57 +01:00

Merge pull request #71 from rbtcollins/patch-1

Wait for spawned thread
This commit is contained in:
Nikolay Kim 2018-02-13 14:58:11 -08:00 committed by GitHub
commit 096dee519c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,7 @@ Here is full source of main.rs file:
```rust ```rust
# use std::thread; # use std::thread;
# extern crate actix_web; extern crate actix_web;
use actix_web::*; use actix_web::*;
fn index(req: HttpRequest) -> &'static str { fn index(req: HttpRequest) -> &'static str {
@ -79,13 +79,16 @@ fn index(req: HttpRequest) -> &'static str {
} }
fn main() { fn main() {
# thread::spawn(|| { # // In the doctest suite we can't run blocking code - deliberately leak a thread
# // If copying this example in show-all mode make sure you skip the thread spawn
# // call.
# thread::spawn(|| {
HttpServer::new( HttpServer::new(
|| Application::new() || Application::new()
.resource("/", |r| r.f(index))) .resource("/", |r| r.f(index)))
.bind("127.0.0.1:8088").expect("Can not bind to 127.0.0.1:8088") .bind("127.0.0.1:8088").expect("Can not bind to 127.0.0.1:8088")
.run(); .run();
# }); # });
} }
``` ```