24 lines
820 B
Rust
24 lines
820 B
Rust
use axum::extract::State;
|
|
use axum::headers::AccessControlMaxAge;
|
|
use axum::response::IntoResponse;
|
|
use axum::{Json, 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),
|
|
)
|
|
}
|