rieter/server/src/repo/mod.rs

13 lines
470 B
Rust
Raw Normal View History

2023-07-11 11:41:56 +00:00
use axum::extract::{Path, State};
use axum::routing::get_service;
use axum::Router;
use tower_http::services::ServeDir;
pub fn router(config: &crate::Config) -> Router<crate::Config> {
// Try to serve packages by default, and try the database files instead if not found
let service = ServeDir::new(&config.pkg_dir).fallback(ServeDir::new(&config.repo_dir));
Router::new()
.route("/*path", get_service(service))
.with_state(config.clone())
}