1pub mod health;
9pub mod static_files;
10pub mod ws;
11
12use std::path::PathBuf;
13use std::sync::Arc;
14
15use axum::Router;
16use axum::routing::get;
17
18use crate::session::SessionStore;
19
20#[derive(Clone)]
22#[non_exhaustive]
23pub struct AppState {
24 pub shell: String,
26 pub pwd: Option<PathBuf>,
28 pub scrollback_limit: usize,
30 pub sessions: Arc<SessionStore>,
32 pub orphan_timeout: std::time::Duration,
34}
35
36pub fn router(
38 shell: String,
39 pwd: Option<PathBuf>,
40 scrollback_limit: usize,
41 sessions: Arc<SessionStore>,
42 orphan_timeout: std::time::Duration,
43) -> Router {
44 let state = AppState {
45 shell,
46 pwd,
47 scrollback_limit,
48 sessions,
49 orphan_timeout,
50 };
51 Router::new()
52 .route("/ws", get(ws::ws_handler))
53 .route("/api/v1/ping", get(health::ping))
54 .route("/", get(static_files::index))
55 .route("/{*path}", get(static_files::static_file))
56 .with_state(state)
57}