cargo_overlay_registry/
lib.rs1use std::sync::Arc;
10
11use axum::routing::{get, put};
12use axum::Router;
13
14pub mod endpoints;
15pub mod http_proxy;
16pub mod registry;
17pub mod state;
18pub mod tls;
19pub mod types;
20
21pub use endpoints::{
22 handle_api_download, handle_api_publish, handle_api_search, handle_config, handle_index_1char,
23 handle_index_2char, handle_index_3char, handle_index_4plus,
24};
25pub use http_proxy::{handle_proxy_connection, HttpProxyState};
26pub use registry::{
27 build_registry, AnyRegistry, BuiltRegistry, DynRegistry, Registry, RegistryBuildOptions,
28 RegistrySpec,
29};
30pub use state::{GenericProxyState, MitmCa, RegistryState};
31pub use tls::generate_self_signed_cert;
32
33pub fn build_registry_router<S: RegistryState + Clone + Send + Sync + 'static>(
35 state: Arc<S>,
36) -> Router {
37 Router::new()
38 .route("/config.json", get(handle_config::<S>))
40 .route("/1/{name}", get(handle_index_1char::<S>))
42 .route("/2/{name}", get(handle_index_2char::<S>))
44 .route("/3/{first_char}/{name}", get(handle_index_3char::<S>))
46 .route(
48 "/{first_two}/{second_two}/{name}",
49 get(handle_index_4plus::<S>),
50 )
51 .route("/api/v1/crates", get(handle_api_search::<S>))
53 .route("/api/v1/crates/new", put(handle_api_publish::<S>))
55 .route(
57 "/api/v1/crates/{crate_name}/{version}/download",
58 get(handle_api_download::<S>),
59 )
60 .with_state(state)
61}