diff --git a/examples/basic.rs b/examples/basic.rs index 932d4fece..fc2a55355 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -68,7 +68,7 @@ fn main() { )) // register simple handle r, handle all methods .handler("/index.html", index) - // with path parameters + // with path parameters .resource("/user/{name}/", |r| r.handler(Method::GET, with_param)) // async handler .resource("/async/{name}", |r| r.async(Method::GET, index_async)) diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index ae94193ed..bfc068799 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -2,7 +2,7 @@ [Quickstart](./qs_1.md) - [Getting Started](./qs_2.md) -- [Actix application](./qs_3.md) +- [Application](./qs_3.md) - [Handler](./qs_4.md) - [Resources and Routes](./qs_5.md) - [Application state](./qs_6.md) diff --git a/guide/src/qs_3.md b/guide/src/qs_3.md index faedb9483..66606206e 100644 --- a/guide/src/qs_3.md +++ b/guide/src/qs_3.md @@ -20,3 +20,29 @@ has same url path prefix: In this example application with `/prefix` prefix and `index.html` resource get created. This resource is available as on `/prefix/index.html` url. + +Multiple applications could be served with one server: + +```rust +extern crate actix_web; +extern crate tokio_core; +use std::net::SocketAddr; +use actix_web::*; +use tokio_core::net::TcpStream; + +fn main() { + HttpServer::::new(vec![ + Application::default("/app1") + .resource("/", |r| r.get(|r| httpcodes::HTTPOk)) + .finish(), + Application::default("/app2") + .resource("/", |r| r.get(|r| httpcodes::HTTPOk)) + .finish(), + Application::default("/") + .resource("/", |r| r.get(|r| httpcodes::HTTPOk)) + .finish(), + ]); +} +``` + +All `/app1` requests route to first application, `/app2` to second and then all other to third.