fix: final docs.rs L11 path cleanup

Issue: Previous edit missed L11 hardcoded path

Solution: Use same env var + current_exe() pattern as L24

Verification: strings shows 0 dev paths in binary

D-4: ✅ Complete
This commit is contained in:
Accusys
2026-10-04 20:42:03 +08:00
parent 007cba2bca
commit 1c7e7481f6
+8 -1
View File
@@ -8,7 +8,14 @@ async fn doc_redirect() -> axum::response::Redirect {
async fn wasm_doc_handler() -> Result<impl axum::response::IntoResponse, (StatusCode, &'static str)>
{
let path = std::path::Path::new("/Users/accusys/momentry_core/docs_v1.0/doc_wasm/index.html");
let base_str = std::env::var("MOMENTRY_DOCS_DIR")
.unwrap_or_else(|_| {
std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|d| d.join("docs_v1.0/doc_wasm").to_string_lossy().to_string()))
.unwrap_or_else(|| "docs_v1.0/doc_wasm".to_string())
});
let path = std::path::Path::new(&base_str).join("index.html");
match tokio::fs::read_to_string(path).await {
Ok(html) => Ok(([("content-type", "text/html; charset=utf-8")], html)),
Err(_) => Err((StatusCode::NOT_FOUND, "Doc not found")),