2023-07-17 23:26:11 +02:00
|
|
|
use std::io;
|
|
|
|
|
2019-06-17 08:48:03 +02:00
|
|
|
use actix_cors::Cors;
|
2020-10-20 00:36:53 +02:00
|
|
|
use actix_web::{http::header, middleware::Logger, App, HttpServer};
|
2018-04-13 03:18:42 +02:00
|
|
|
|
|
|
|
mod user;
|
|
|
|
|
2020-09-12 17:49:45 +02:00
|
|
|
#[actix_web::main]
|
2023-07-17 23:26:11 +02:00
|
|
|
async fn main() -> io::Result<()> {
|
2022-03-15 18:32:27 +01:00
|
|
|
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
2018-04-13 03:18:42 +02:00
|
|
|
|
2023-07-17 23:26:11 +02:00
|
|
|
log::info!("starting HTTP server at http://localhost:8080");
|
|
|
|
|
2019-03-29 21:43:03 +01:00
|
|
|
HttpServer::new(move || {
|
2018-05-08 20:08:43 +02:00
|
|
|
App::new()
|
2019-03-29 21:43:03 +01:00
|
|
|
.wrap(
|
2020-10-20 00:36:53 +02:00
|
|
|
Cors::default()
|
2023-07-17 23:26:11 +02:00
|
|
|
.allowed_origin("http://localhost:8081")
|
2018-05-08 20:08:43 +02:00
|
|
|
.allowed_methods(vec!["GET", "POST"])
|
|
|
|
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
|
|
|
|
.allowed_header(header::CONTENT_TYPE)
|
2020-10-20 00:36:53 +02:00
|
|
|
.supports_credentials()
|
|
|
|
.max_age(3600),
|
2019-03-29 21:43:03 +01:00
|
|
|
)
|
|
|
|
.wrap(Logger::default())
|
2020-10-20 00:36:53 +02:00
|
|
|
.service(user::info)
|
2019-03-10 03:03:09 +01:00
|
|
|
})
|
2022-03-15 18:32:27 +01:00
|
|
|
.bind(("127.0.0.1", 8080))?
|
2023-07-18 02:01:26 +02:00
|
|
|
.workers(2)
|
2019-12-25 17:48:33 +01:00
|
|
|
.run()
|
2019-12-16 08:09:54 +01:00
|
|
|
.await
|
2018-04-13 03:18:42 +02:00
|
|
|
}
|