AkurAI Build
Menu

Public repository / e27a0f4c5383eb7013e2b86b909220f35c5e2fc9

AkurAI-Drive / backend/src/pages.rs

Latest change e27a0f4c5383eb7013e2b86b909220f35c5e2fc9 - fmt: rustfmt after request-logging change by agent

use axum::{
    http::{HeaderMap, StatusCode, header},
    response::{Html, IntoResponse, Response},
};

use crate::session;

/// `GET /app` — the authenticated dashboard. Redirects to `/auth/login` without a
/// valid session, otherwise serves the dashboard HTML.
///
/// NOTE: `static/app.html` is the real dashboard, provided by a separate frontend
/// agent. A minimal placeholder is committed so the crate compiles standalone; the
/// real file replaces it without any code change here.
pub async fn app(headers: HeaderMap) -> Response {
    match session::lookup_session(&headers) {
        Some(_) => Html(include_str!("../static/app.html")).into_response(),
        None => (StatusCode::FOUND, [(header::LOCATION, "/auth/login")]).into_response(),
    }
}

/// `GET /js/monitor-client.js` — browser-side Monitor shipper.
pub async fn monitor_client() -> Response {
    (
        [(header::CONTENT_TYPE, "text/javascript; charset=utf-8")],
        include_str!("../static/js/monitor-client.js"),
    )
        .into_response()
}