pub mod health;
pub mod static_files;
pub mod ws;
use std::path::PathBuf;
use std::sync::Arc;
use axum::Router;
use axum::routing::get;
use crate::session::SessionStore;
#[derive(Clone)]
#[non_exhaustive]
pub struct AppState {
pub shell: String,
pub pwd: Option<PathBuf>,
pub scrollback_limit: usize,
pub sessions: Arc<SessionStore>,
pub orphan_timeout: std::time::Duration,
}
pub fn router(
shell: String,
pwd: Option<PathBuf>,
scrollback_limit: usize,
sessions: Arc<SessionStore>,
orphan_timeout: std::time::Duration,
) -> Router {
let state = AppState {
shell,
pwd,
scrollback_limit,
sessions,
orphan_timeout,
};
Router::new()
.route("/ws", get(ws::ws_handler))
.route("/api/v1/ping", get(health::ping))
.route("/", get(static_files::index))
.route("/{*path}", get(static_files::static_file))
.with_state(state)
}