Archived
feat: el-ide — native IDE for engram-lang, LSP, type graph, plugin ecosystem
Axum HTTP server (port 7771) serving a single-page IDE with CodeMirror 6 syntax highlighting for engram-lang, a force-directed type graph visualizer, LSP (completions, hover, diagnostics), SSE-streamed build/run output, a plugin host with five first-party plugins, and a reasoning panel that proxies to engram-server. 28 tests across three crates, zero warnings.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//! Embedded static assets via rust-embed.
|
||||
|
||||
use axum::{
|
||||
extract::Path,
|
||||
http::{header, StatusCode},
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "../../ide/"]
|
||||
pub struct Assets;
|
||||
|
||||
/// Serve `index.html` at the root path.
|
||||
pub async fn serve_index() -> impl IntoResponse {
|
||||
serve_file("index.html")
|
||||
}
|
||||
|
||||
/// Serve any embedded asset by path.
|
||||
pub async fn serve_asset(Path(path): Path<String>) -> impl IntoResponse {
|
||||
serve_file(&path)
|
||||
}
|
||||
|
||||
fn serve_file(path: &str) -> Response {
|
||||
match Assets::get(path) {
|
||||
Some(content) => {
|
||||
let mime = mime_guess::from_path(path)
|
||||
.first_or_octet_stream()
|
||||
.to_string();
|
||||
(
|
||||
StatusCode::OK,
|
||||
[(header::CONTENT_TYPE, mime)],
|
||||
content.data.to_vec(),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
None => {
|
||||
// For SPA routing, fall back to index.html
|
||||
match Assets::get("index.html") {
|
||||
Some(content) => (
|
||||
StatusCode::OK,
|
||||
[(header::CONTENT_TYPE, "text/html; charset=utf-8".to_string())],
|
||||
content.data.to_vec(),
|
||||
)
|
||||
.into_response(),
|
||||
None => StatusCode::NOT_FOUND.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user