1mod health;
9mod static_files;
10mod 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)]
22pub struct AppState {
23 pub shell: String,
25 pub pwd: Option<PathBuf>,
27 pub scrollback_limit: usize,
29 pub sessions: Arc<SessionStore>,
31}
32
33pub fn router(
35 shell: String,
36 pwd: Option<PathBuf>,
37 scrollback_limit: usize,
38 sessions: Arc<SessionStore>,
39) -> Router {
40 let state = AppState {
41 shell,
42 pwd,
43 scrollback_limit,
44 sessions,
45 };
46 Router::new()
47 .route("/ws", get(ws::ws_handler))
48 .route("/api/v1/ping", get(health::ping))
49 .route("/", get(static_files::index))
50 .route("/{*path}", get(static_files::static_file))
51 .with_state(state)
52}