2023-07-07 19:22:30 +00:00
|
|
|
use axum::extract::State;
|
|
|
|
use axum::response::IntoResponse;
|
2023-12-22 18:19:07 +00:00
|
|
|
use axum::Json;
|
|
|
|
use axum_extra::headers::AccessControlMaxAge;
|
|
|
|
use axum_extra::TypedHeader;
|
2023-07-07 19:22:30 +00:00
|
|
|
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),
|
|
|
|
)
|
|
|
|
}
|