magnetar/fe_calckey/src/manifest.rs

25 lines
840 B
Rust

use axum::extract::State;
use axum::response::IntoResponse;
use axum::Json;
use axum_extra::headers::AccessControlMaxAge;
use axum_extra::TypedHeader;
use magnetar_common::config::MagnetarConfig;
use serde_json::Value;
use std::time::Duration;
pub async fn handle_manifest(State(config): State<&'static MagnetarConfig>) -> impl IntoResponse {
let manifest = include_str!("../frontend/assets-be/manifest.json");
let mut manifest_json: Value = serde_json::from_str(manifest).unwrap();
manifest_json["short_name"] = Value::String(config.branding.name.clone());
manifest_json["name"] = Value::String(config.branding.name.clone());
// TODO: Pull from instance metadata
(
TypedHeader(AccessControlMaxAge::from(Duration::from_secs(
60 * 60 * 24 * 7,
))),
Json(manifest_json),
)
}