2020-09-12 17:21:54 +02:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2019-06-19 06:20:50 +02:00
|
|
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
|
|
|
|
|
|
|
// <combine>
|
|
|
|
struct State1;
|
|
|
|
struct State2;
|
|
|
|
|
2020-09-12 17:21:54 +02:00
|
|
|
#[actix_web::main]
|
2019-12-28 17:15:22 +01:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2019-06-19 06:20:50 +02:00
|
|
|
HttpServer::new(|| {
|
|
|
|
App::new()
|
|
|
|
.service(
|
|
|
|
web::scope("/app1")
|
2022-02-26 04:56:24 +01:00
|
|
|
.app_data(web::Data::new(State1))
|
|
|
|
.route("/", web::to(HttpResponse::Ok)),
|
2020-09-12 17:21:54 +02:00
|
|
|
)
|
2019-06-19 06:20:50 +02:00
|
|
|
.service(
|
|
|
|
web::scope("/app2")
|
2022-02-26 04:56:24 +01:00
|
|
|
.app_data(web::Data::new(State2))
|
|
|
|
.route("/", web::to(HttpResponse::Ok)),
|
2020-09-12 17:21:54 +02:00
|
|
|
)
|
2019-06-19 06:20:50 +02:00
|
|
|
})
|
2022-02-26 04:56:24 +01:00
|
|
|
.bind(("127.0.0.1", 8080))?
|
2019-06-19 06:20:50 +02:00
|
|
|
.run()
|
2019-12-28 17:15:22 +01:00
|
|
|
.await
|
2019-06-19 06:20:50 +02:00
|
|
|
}
|
|
|
|
// </combine>
|