-
Notifications
You must be signed in to change notification settings - Fork 130
/
main.rs
32 lines (28 loc) · 860 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use actix_web::{web, App, HttpResponse, HttpServer};
use env_logger as elog;
mod config;
mod handler;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
elog::from_env(elog::Env::default().default_filter_or("info")).init();
let port: u16 = match std::env::var("PORT") {
Ok(v) => v.parse().unwrap(),
Err(_) => 8080,
};
// Create the HTTP server
HttpServer::new(|| {
App::new()
.wrap(actix_web::middleware::Logger::default())
.configure(config::configure)
.route("/", web::get().to(handler::index))
.route("/", web::post().to(handler::index))
.route(
"/health/{_:(readiness|liveness)}",
web::get().to(HttpResponse::Ok),
)
})
.bind(("127.0.0.1", port))?
.workers(1)
.run()
.await
}