94392e72d8
This commit introduces a new API endpoint `/api/oneliners` that allows authenticated users to retrieve a list of their recent oneliners. The endpoint supports conditional GET requests using the `ETag` header for efficient caching. It also allows specifying a time window for the oneliners via the `hours` query parameter, with sensible defaults and clamping. The implementation includes: - A new route handler `handle_oneliners`. - A new type `OnelinerWatermark` for tracking user-specific timestamps. - Logic for scanning user data directories, filtering by time, and handling deleted cases. - Test cases to cover various scenarios, including caching, time windowing, and edge cases.
53 lines
1.6 KiB
Rust
53 lines
1.6 KiB
Rust
mod bulk;
|
|
mod case_actions;
|
|
mod debug;
|
|
mod health;
|
|
mod login;
|
|
mod oneliners;
|
|
mod upload;
|
|
pub(crate) mod user_web;
|
|
pub(crate) mod web;
|
|
|
|
use axum::routing::{get, post};
|
|
use axum::Router;
|
|
|
|
use crate::AppState;
|
|
|
|
pub fn api_router() -> Router<AppState> {
|
|
Router::new()
|
|
.route("/api/health", get(health::handle_health))
|
|
.route("/api/debug/whoami", get(debug::handle_whoami))
|
|
.route("/api/upload", post(upload::handle_upload))
|
|
.route("/api/oneliners", get(oneliners::handle_oneliners))
|
|
.route("/web/login", get(login::handle_login_page).post(login::handle_login_submit))
|
|
.route("/web/logout", post(login::handle_logout))
|
|
.route("/web/cases", get(user_web::handle_my_cases))
|
|
.route("/web/cases/{case_id}", get(user_web::handle_case_detail))
|
|
.route(
|
|
"/web/cases/{case_id}/analyze",
|
|
post(case_actions::handle_analyze_case),
|
|
)
|
|
.route(
|
|
"/web/cases/{case_id}/delete",
|
|
post(case_actions::handle_delete_case),
|
|
)
|
|
.route(
|
|
"/web/cases/{case_id}/reset",
|
|
post(case_actions::handle_reset_case),
|
|
)
|
|
.route(
|
|
"/web/cases/undo-delete",
|
|
post(case_actions::handle_undo_delete),
|
|
)
|
|
.route("/web/cases/bulk", post(bulk::handle_bulk_action))
|
|
.route(
|
|
"/web/cases/{case_id}/document",
|
|
get(case_actions::handle_document_view),
|
|
)
|
|
.route("/web/", get(web::handle_case_list))
|
|
.route(
|
|
"/web/audio/{user}/{case_id}/{filename}",
|
|
get(web::handle_audio),
|
|
)
|
|
}
|