use std::sync::Arc;
use axum::routing::{get, post};
use axum::Router;
use crate::storage::Cache;
use super::handlers;
#[derive(Debug, Clone)]
pub struct AppState {
pub cache: Arc<Cache>,
pub allow_scan: bool,
}
pub fn router(cache: Cache, allow_scan: bool) -> Router {
let state = AppState {
cache: Arc::new(cache),
allow_scan,
};
Router::new()
.route("/", get(handlers::index))
.route("/reports/:owner/:name", get(handlers::report))
.route("/api/reports/:owner/:name", get(handlers::report_json))
.route("/scans", post(handlers::scan))
.route("/static/*path", get(handlers::static_asset))
.fallback(handlers::not_found)
.with_state(state)
}