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 18:31:40 +02:00
|
|
|
// <make_app>
|
2018-05-24 05:39:15 +02:00
|
|
|
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-24 18:31:40 +02:00
|
|
|
.prefix("/app")
|
|
|
|
.resource("/index.html", |r| r.method(Method::GET).f(index))
|
|
|
|
.finish()
|
2018-05-23 22:01:33 +02:00
|
|
|
// </make_app>
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_server() {
|
2018-05-24 18:31:40 +02:00
|
|
|
// <run_server>
|
2018-05-24 05:39:15 +02:00
|
|
|
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())),
|
|
|
|
]
|
|
|
|
});
|
2018-05-24 18:31:40 +02:00
|
|
|
// </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
|
|
|
}
|