use axum::body::Body;
use axum::http::{Response, StatusCode};
const INFO_PAGE: &str = r#"<!DOCTYPE html>
<html>
<head><title>Torc Server</title></head>
<body style="font-family: sans-serif; max-width: 600px; margin: 80px auto; text-align: center;">
<h1>Torc API Server</h1>
<p>The API server is running. To access the web dashboard, start <code>torc-dash</code>:</p>
<pre style="background: #f4f4f4; padding: 12px; border-radius: 4px;">torc-dash --url http://<this-server>:<port></pre>
<p style="color: #666; font-size: 0.9em;">See <code>torc-dash --help</code> for options.</p>
</body>
</html>"#;
pub fn serve_dashboard(path: &str) -> Option<Response<Body>> {
let path = path.trim_start_matches('/');
if path.is_empty() || path == "dashboard" || path == "dashboard/" {
Some(
Response::builder()
.status(StatusCode::OK)
.header("Content-Type", "text/html; charset=utf-8")
.body(Body::from(INFO_PAGE))
.expect("Failed to build response"),
)
} else {
None
}
}