2025-11-04 16:27:54 +01:00
|
|
|
//! API route handlers for the backend server.
|
|
|
|
|
//!
|
|
|
|
|
//! This module contains all the HTTP endpoint handlers organized by functionality:
|
|
|
|
|
//! - Contact form handling
|
|
|
|
|
//! - Health checks
|
|
|
|
|
//! - Application metadata
|
2025-11-04 09:17:18 +01:00
|
|
|
|
2025-11-04 16:27:54 +01:00
|
|
|
use poem_openapi::Tags;
|
2025-11-04 09:17:18 +01:00
|
|
|
|
2025-11-04 16:27:54 +01:00
|
|
|
mod contact;
|
|
|
|
|
mod health;
|
2025-11-04 09:17:18 +01:00
|
|
|
mod meta;
|
2025-11-04 16:27:54 +01:00
|
|
|
|
|
|
|
|
use crate::settings::Settings;
|
2025-11-04 09:17:18 +01:00
|
|
|
|
|
|
|
|
#[derive(Tags)]
|
|
|
|
|
enum ApiCategory {
|
2025-11-04 16:27:54 +01:00
|
|
|
Contact,
|
2025-11-04 09:17:18 +01:00
|
|
|
Health,
|
2025-11-04 16:27:54 +01:00
|
|
|
Meta,
|
2025-11-04 09:17:18 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-04 16:27:54 +01:00
|
|
|
pub(crate) struct Api {
|
|
|
|
|
contact: contact::ContactApi,
|
|
|
|
|
health: health::HealthApi,
|
|
|
|
|
meta: meta::MetaApi,
|
|
|
|
|
}
|
2025-11-04 09:17:18 +01:00
|
|
|
|
2025-11-04 16:27:54 +01:00
|
|
|
impl From<&Settings> for Api {
|
|
|
|
|
fn from(value: &Settings) -> Self {
|
|
|
|
|
let contact = contact::ContactApi::from(value.clone().email);
|
|
|
|
|
let health = health::HealthApi;
|
|
|
|
|
let meta = meta::MetaApi::from(&value.application);
|
|
|
|
|
Self {
|
|
|
|
|
contact,
|
|
|
|
|
health,
|
|
|
|
|
meta,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Api {
|
|
|
|
|
pub fn apis(self) -> (contact::ContactApi, health::HealthApi, meta::MetaApi) {
|
|
|
|
|
(self.contact, self.health, self.meta)
|
|
|
|
|
}
|
|
|
|
|
}
|