Rust implementation of OCI Distribution Spec with granular access control
1use serde_json::{json, Value};
2use std::sync::Arc;
3
4use crate::{state, utils};
5use axum::{
6 extract::{Path, State},
7 response::Json,
8};
9
10pub(crate) async fn index(State(data): State<Arc<state::App>>) -> Json<Value> {
11 let status = data.server_status.lock().await;
12 log::info!("meta/index: server_status: {}", status);
13 Json(json!({
14 "server": format!("grain {} status {}", utils::get_build_info(), status)
15 }))
16}
17
18pub(crate) async fn catch_all_head(Path(path): Path<String>) -> String {
19 log::error!("meta/catch_all: HEAD {}", path);
20 "Not found".to_string()
21}
22
23pub(crate) async fn catch_all_get(Path(path): Path<String>) -> String {
24 log::error!("meta/catch_all: GET {}", path);
25 "Not found".to_string()
26}
27
28pub(crate) async fn catch_all_post(Path(path): Path<String>) -> String {
29 log::error!("meta/catch_all: POST {}", path);
30 "Not found".to_string()
31}
32
33pub(crate) async fn catch_all_put(Path(path): Path<String>) -> String {
34 log::error!("meta/catch_all: PUT {}", path);
35 "Not found".to_string()
36}
37
38pub(crate) async fn catch_all_patch(Path(path): Path<String>) -> String {
39 log::error!("meta/catch_all: PATCH {}", path);
40 "Not found".to_string()
41}
42
43pub(crate) async fn catch_all_delete(Path(path): Path<String>) -> String {
44 log::error!("meta/catch_all: DELETE {}", path);
45 "Not found".to_string()
46}