Page MenuHomeDevCentral

requests.rs
No OneTemporary

requests.rs

//!
//! HTTP requests handled by the microservice.
//!
use axum::http::StatusCode;
use limiting_factor_axum::api::replies::{ApiJsonResponse, ApiResponse};
use crate::registry::{Registry, Repository};
pub async fn status() -> &'static str {
"ALIVE"
}
// -------------------------------------------------------------
// /docker/registry
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pub async fn get_registry_stats() -> ApiJsonResponse<Registry> {
Registry::with_default_location()
.into_json_response()
}
// -------------------------------------------------------------
// /docker/registry/repository
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pub async fn get_repository_info(repository_name: String) -> ApiJsonResponse<Repository> {
let repository = Registry::with_default_location()
.get_repository(&repository_name);
match repository {
None => Err(StatusCode::BAD_REQUEST),
Some(repo) => {
if repo.exists() {
Ok(repo)
} else {
Err(StatusCode::NOT_FOUND)
}
}
}.into_json_response()
}
pub async fn get_all_repositories() -> ApiJsonResponse<Vec<Repository>> {
Registry::with_default_location()
.get_all_repositories()
.into_json_response()
}
pub async fn find_repository_by_layer(hash: String) -> ApiJsonResponse<Vec<Repository>> {
if !Repository::is_valid_hash(&hash) {
return Err(StatusCode::BAD_REQUEST).into_json_response();
}
Registry::with_default_location()
.get_repositories_by_layer_hash(&hash)
.into_json_response()
}
pub async fn find_repository_by_image(hash: String) -> ApiJsonResponse<Vec<Repository>> {
if !Repository::is_valid_hash(&hash) {
return Err(StatusCode::BAD_REQUEST).into_json_response();
}
Registry::with_default_location()
.get_repositories_by_image_hash(&hash)
.into_json_response()
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 7, 15:25 (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4249541
Default Alt Text
requests.rs (1 KB)

Event Timeline