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