mod.rs
⎇
Raw
1use std::sync::Arc;
2
3use axum::routing::{delete, get, post};
4use axum::Router;
5
6use crate::error::AppState;
7
8mod auth;
9mod common;
10mod files;
11mod spa;
12
13pub fn router(state: Arc<AppState>) -> Router {
14 Router::new()
15 .route("/api/auth/login", post(auth::login))
16 .route("/api/auth/logout", post(auth::logout))
17 .route("/api/auth/me", get(auth::me))
18 .route("/api/auth/setup", post(auth::setup))
19 .route("/api/files/{root_id}", get(files::list_root))
20 .route("/api/files/{root_id}/{*path}", get(files::file_get))
21 .route("/api/files/{root_id}", post(files::dispatch_root))
22 .route("/api/files/{root_id}/{*path}", post(files::dispatch))
23 .route("/api/files/{root_id}/{*path}", delete(files::delete))
24 .fallback(spa::fallback)
25 .with_state(state)
26}
27