2018-05-23 22:01:33 +02:00
|
|
|
#![allow(unused)]
|
2018-05-23 21:28:12 +02:00
|
|
|
extern crate actix_web;
|
2018-05-24 05:39:15 +02:00
|
|
|
use actix_web::{http::Method, server, App, HttpRequest, HttpResponse, Responder};
|
2018-05-23 21:28:12 +02:00
|
|
|
|
2018-05-23 22:01:33 +02:00
|
|
|
mod state;
|
|
|
|
|
|
|
|
fn make_app() {
|
2018-05-24 05:39:15 +02:00
|
|
|
// <make_app>
|
|
|
|
fn index(req: HttpRequest) -> impl Responder {
|
|
|
|
"Hello world!"
|
|
|
|
}
|
2018-05-23 21:28:12 +02:00
|
|
|
|
2018-05-24 05:39:15 +02:00
|
|
|
let app = App::new()
|
2018-05-23 22:01:33 +02:00
|
|
|
.prefix("/app")
|
|
|
|
.resource("/index.html", |r| r.method(Method::GET).f(index))
|
|
|
|
.finish()
|
|
|
|
// </make_app>
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_server() {
|
2018-05-24 05:39:15 +02:00
|
|
|
// <run_server>
|
|
|
|
let server = server::new(|| {
|
|
|
|
vec![
|
|
|
|
App::new()
|
|
|
|
.prefix("/app1")
|
|
|
|
.resource("/", |r| r.f(|r| HttpResponse::Ok())),
|
|
|
|
App::new()
|
|
|
|
.prefix("/app2")
|
|
|
|
.resource("/", |r| r.f(|r| HttpResponse::Ok())),
|
|
|
|
App::new().resource("/", |r| r.f(|r| HttpResponse::Ok())),
|
|
|
|
]
|
|
|
|
});
|
|
|
|
// </run_server>
|
2018-05-23 22:01:33 +02:00
|
|
|
}
|
|
|
|
|
2018-05-23 21:28:12 +02:00
|
|
|
fn main() {
|
2018-05-23 22:01:33 +02:00
|
|
|
make_app();
|
|
|
|
run_server();
|
|
|
|
state::test();
|
2018-05-23 21:28:12 +02:00
|
|
|
}
|