ips/pkg6depotd/src/http/routes.rs
Till Wegmueller ff0b9f4319
Add support for file URL without algorithm and refactor JSON serialization for Python-style compatibility
- Added `/file/1/{digest}` route to support file retrieval without specifying the algorithm.
- Implemented a Python-compatible JSON serializer to ensure consistent formatting for catalog artifacts.
- Replaced `HashMap` with `BTreeMap` for deterministic ordering in catalog serialization and updates.
- Updated integration tests to validate the new route functionality and ensure response correctness.
- Refactored `format_iso8601_basic` to improve timestamp formatting consistency.
2025-12-22 22:42:56 +01:00

46 lines
1.6 KiB
Rust

use crate::http::admin;
use crate::http::handlers::{catalog, file, info, manifest, publisher, versions};
use crate::repo::DepotRepo;
use axum::{
Router,
routing::{get, post},
};
use std::sync::Arc;
use tower_http::trace::TraceLayer;
pub fn app_router(state: Arc<DepotRepo>) -> Router {
Router::new()
.route("/versions/0/", get(versions::get_versions))
.route(
"/{publisher}/catalog/1/{filename}",
get(catalog::get_catalog_v1).head(catalog::get_catalog_v1),
)
.route(
"/{publisher}/manifest/0/{fmri}",
get(manifest::get_manifest).head(manifest::get_manifest),
)
.route(
"/{publisher}/manifest/1/{fmri}",
get(manifest::get_manifest).head(manifest::get_manifest),
)
.route(
"/{publisher}/file/0/{algo}/{digest}",
get(file::get_file).head(file::get_file),
)
.route(
"/{publisher}/file/1/{algo}/{digest}",
get(file::get_file).head(file::get_file),
)
.route(
"/{publisher}/file/1/{digest}",
get(file::get_file_no_algo).head(file::get_file_no_algo),
)
.route("/{publisher}/info/0/{fmri}", get(info::get_info))
.route("/{publisher}/publisher/0", get(publisher::get_publisher_v0))
.route("/{publisher}/publisher/1", get(publisher::get_publisher_v1))
// Admin API over HTTP
.route("/admin/health", get(admin::health))
.route("/admin/auth/check", post(admin::auth_check))
.layer(TraceLayer::new_for_http())
.with_state(state)
}