GeneIT/geneit_backend/src/main.rs

53 lines
1.8 KiB
Rust
Raw Normal View History

2023-05-24 14:19:46 +00:00
use actix_remote_ip::RemoteIPConfig;
use actix_web::middleware::Logger;
2023-05-24 12:38:18 +00:00
use actix_web::{web, App, HttpServer};
use geneit_backend::app_config::AppConfig;
2023-05-31 13:52:49 +00:00
use geneit_backend::controllers::{auth_controller, config_controller, user_controller};
2023-05-24 12:38:18 +00:00
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
log::info!("Start to listen on {}", AppConfig::get().listen_address);
HttpServer::new(|| {
App::new()
2023-05-24 14:19:46 +00:00
.wrap(Logger::default())
.app_data(web::Data::new(RemoteIPConfig {
proxy: AppConfig::get().proxy_ip.clone(),
}))
2023-05-24 12:38:18 +00:00
// Config controller
.route("/", web::get().to(config_controller::home))
.route(
"/config/static",
web::get().to(config_controller::static_config),
)
2023-05-24 14:19:46 +00:00
// Auth controller
.route(
"/auth/create_account",
web::post().to(auth_controller::create_account),
)
2023-05-31 11:56:18 +00:00
.route(
"/auth/request_reset_password",
web::post().to(auth_controller::request_reset_password),
)
.route(
"/auth/check_reset_password_token",
web::post().to(auth_controller::check_reset_password_token),
)
2023-05-31 11:33:26 +00:00
.route(
"/auth/reset_password",
web::post().to(auth_controller::reset_password),
)
2023-05-31 13:17:00 +00:00
.route(
"/auth/password_login",
web::post().to(auth_controller::password_login),
)
2023-05-31 13:52:49 +00:00
// User controller
.route("/user/info", web::get().to(user_controller::auth_info))
2023-05-24 12:38:18 +00:00
})
.bind(AppConfig::get().listen_address.as_str())?
.run()
.await
2023-05-24 09:37:02 +00:00
}