GeneIT/geneit_backend/src/controllers/server_controller.rs

38 lines
1.1 KiB
Rust

use crate::app_config::{AppConfig, OIDCProvider};
use crate::constants::StaticConstraints;
use crate::models::{CoupleState, CoupleStateDesc};
use crate::utils::countries_utils;
use crate::utils::countries_utils::CountryCode;
use actix_web::{HttpResponse, Responder};
/// Default hello route
pub async fn home() -> impl Responder {
HttpResponse::Ok().json("GeneIT API service.")
}
#[derive(Debug, Clone, serde::Serialize)]
struct ServerConfig<'a> {
constraints: StaticConstraints,
mail: &'static str,
oidc_providers: Vec<OIDCProvider<'a>>,
countries: Vec<CountryCode>,
couples_states: Vec<CoupleStateDesc>,
}
impl Default for ServerConfig<'_> {
fn default() -> Self {
Self {
mail: AppConfig::get().mail_sender.as_str(),
constraints: StaticConstraints::default(),
oidc_providers: AppConfig::get().openid_providers(),
countries: countries_utils::get_list(),
couples_states: CoupleState::states_list(),
}
}
}
/// Get server configuration
pub async fn server_config() -> impl Responder {
HttpResponse::Ok().json(ServerConfig::default())
}