mirror of
https://github.com/actix/actix-web.git
synced 2024-11-08 18:19:30 +00:00
update guide examples
This commit is contained in:
parent
d0c01c2cdd
commit
c47e2ccfee
2 changed files with 6 additions and 4 deletions
|
@ -58,7 +58,9 @@ After that, application instance can be used with `HttpServer` to listen for inc
|
||||||
connections. Server accepts function that should return `HttpHandler` instance:
|
connections. Server accepts function that should return `HttpHandler` instance:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
HttpServer::new(|| app).serve::<_, ()>("127.0.0.1:8088");
|
HttpServer::new(|| app)
|
||||||
|
.bind("127.0.0.1:8088")?
|
||||||
|
.start();
|
||||||
```
|
```
|
||||||
|
|
||||||
That's it. Now, compile and run the program with cargo run.
|
That's it. Now, compile and run the program with cargo run.
|
||||||
|
@ -92,5 +94,5 @@ fn main() {
|
||||||
|
|
||||||
Note on `actix` crate. Actix web framework is built on top of actix actor library.
|
Note on `actix` crate. Actix web framework is built on top of actix actor library.
|
||||||
`actix::System` initializes actor system, `HttpServer` is an actor and must run within
|
`actix::System` initializes actor system, `HttpServer` is an actor and must run within
|
||||||
proper configured actix system. For more information please check
|
properly configured actix system. For more information please check
|
||||||
[actix documentation](https://actix.github.io/actix/actix/)
|
[actix documentation](https://actix.github.io/actix/actix/)
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn main() {
|
||||||
HttpServer::<TcpStream, SocketAddr, _, _>::new(
|
HttpServer::<TcpStream, SocketAddr, _, _>::new(
|
||||||
|| Application::new()
|
|| Application::new()
|
||||||
.resource("/", |r| r.f(|_| httpcodes::HTTPOk)))
|
.resource("/", |r| r.f(|_| httpcodes::HTTPOk)))
|
||||||
.threads(4); // <- Start 4 threads
|
.threads(4); // <- Start 4 workers
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ Note on *HTTP/2.0* protocol over tls without prior knowledge, it requires
|
||||||
`openssl` has `alpn ` support.
|
`openssl` has `alpn ` support.
|
||||||
|
|
||||||
Please check [example](https://github.com/actix/actix-web/tree/master/examples/tls)
|
Please check [example](https://github.com/actix/actix-web/tree/master/examples/tls)
|
||||||
for concrete example.
|
for full example.
|
||||||
|
|
||||||
## Keep-Alive
|
## Keep-Alive
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue