mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
update guide
This commit is contained in:
parent
ca76dff5a7
commit
8dbbb0ee07
@ -51,10 +51,11 @@ request handler with the application's `resource` on a particular *HTTP method*
|
|||||||
```
|
```
|
||||||
|
|
||||||
After that, the application instance can be used with `HttpServer` to listen for incoming
|
After that, the application instance can be used with `HttpServer` to listen for incoming
|
||||||
connections. The server accepts a function that should return an `HttpHandler` instance:
|
connections. The server accepts a function that should return an `HttpHandler` instance.
|
||||||
|
For simplicity `server::new` could be used, this function is shortcut for `HttpServer::new`:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
HttpServer::new(
|
server::new(
|
||||||
|| App::new()
|
|| App::new()
|
||||||
.resource("/", |r| r.f(index)))
|
.resource("/", |r| r.f(index)))
|
||||||
.bind("127.0.0.1:8088")?
|
.bind("127.0.0.1:8088")?
|
||||||
@ -80,7 +81,7 @@ fn main() {
|
|||||||
# // If copying this example in show-all mode, make sure you skip the thread spawn
|
# // If copying this example in show-all mode, make sure you skip the thread spawn
|
||||||
# // call.
|
# // call.
|
||||||
# thread::spawn(|| {
|
# thread::spawn(|| {
|
||||||
server::HttpServer::new(
|
server::new(
|
||||||
|| App::new()
|
|| App::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")
|
||||||
|
Loading…
Reference in New Issue
Block a user