Author:
Hash:
Timestamp:
+43 -47 +/-6 browse
Kevin Schoon [me@kevinschoon.com]
d285c8eb31c8079ddf4f0b3ccfc1c8721cb04093
Wed, 09 Apr 2025 13:55:55 +0000 (6 months ago)
| 1 | diff --git a/src/axum/handlers.rs b/src/axum/handlers.rs |
| 2 | index ef8f52d..3fa69bc 100644 |
| 3 | --- a/src/axum/handlers.rs |
| 4 | +++ b/src/axum/handlers.rs |
| 5 | @@ -1,34 +1,34 @@ |
| 6 | - use std::{str::FromStr, sync::Arc}; |
| 7 | - |
| 8 | - use super::{AppState, error::Error}; |
| 9 | - use crate::Namespace; |
| 10 | - use axum::{ |
| 11 | - Extension, Json, |
| 12 | - body::HttpBody, |
| 13 | - extract::{FromRequest, Path, Query, Request, State}, |
| 14 | - http::StatusCode, |
| 15 | - response::{IntoResponse, Response}, |
| 16 | - }; |
| 17 | - use bytes::{Buf, Bytes}; |
| 18 | - use futures::TryStreamExt; |
| 19 | - use oci_spec::distribution::TagList; |
| 20 | - use serde_json::json; |
| 21 | - |
| 22 | - pub async fn index() -> Result<Json<serde_json::Value>, Error> { |
| 23 | - Ok(Json(json!({}))) |
| 24 | - } |
| 25 | - |
| 26 | - pub(crate) async fn read_tags( |
| 27 | - State(state): State<Arc<AppState>>, |
| 28 | - Path(name): Path<String>, |
| 29 | - ) -> Result<Json<TagList>, Error> { |
| 30 | - let namespace = Namespace::from_str(&name)?; |
| 31 | - let tags = state.oci.list_tags(&namespace).await?; |
| 32 | - Ok(Json(tags)) |
| 33 | - } |
| 34 | - |
| 35 | - pub async fn read_referrers() {} |
| 36 | - |
| 37 | - pub async fn delete_manifest() {} |
| 38 | - pub async fn delete_tag() {} |
| 39 | - pub async fn delete_blob() {} |
| 40 | + // use std::{str::FromStr, sync::Arc}; |
| 41 | + // |
| 42 | + // use super::{AppState, error::Error}; |
| 43 | + // use crate::Namespace; |
| 44 | + // use axum::{ |
| 45 | + // Extension, Json, |
| 46 | + // body::HttpBody, |
| 47 | + // extract::{FromRequest, Path, Query, Request, State}, |
| 48 | + // http::StatusCode, |
| 49 | + // response::{IntoResponse, Response}, |
| 50 | + // }; |
| 51 | + // use bytes::{Buf, Bytes}; |
| 52 | + // use futures::TryStreamExt; |
| 53 | + // use oci_spec::distribution::TagList; |
| 54 | + // use serde_json::json; |
| 55 | + // |
| 56 | + // pub async fn index() -> Result<Json<serde_json::Value>, Error> { |
| 57 | + // Ok(Json(json!({}))) |
| 58 | + // } |
| 59 | + // |
| 60 | + // pub(crate) async fn read_tags( |
| 61 | + // State(state): State<Arc<AppState>>, |
| 62 | + // Path(name): Path<String>, |
| 63 | + // ) -> Result<Json<TagList>, Error> { |
| 64 | + // let namespace = Namespace::from_str(&name)?; |
| 65 | + // let tags = state.oci.list_tags(&namespace).await?; |
| 66 | + // Ok(Json(tags)) |
| 67 | + // } |
| 68 | + // |
| 69 | + // pub async fn read_referrers() {} |
| 70 | + // |
| 71 | + // pub async fn delete_manifest() {} |
| 72 | + // pub async fn delete_tag() {} |
| 73 | + // pub async fn delete_blob() {} |
| 74 | diff --git a/src/axum/handlers_blob.rs b/src/axum/handlers_blob.rs |
| 75 | index ac30b2b..e635ae8 100644 |
| 76 | --- a/src/axum/handlers_blob.rs |
| 77 | +++ b/src/axum/handlers_blob.rs |
| 78 | @@ -44,7 +44,7 @@ pub async fn initiate(State(state): State<Arc<AppState>>) -> Result<Response, Er |
| 79 | |
| 80 | pub async fn read( |
| 81 | State(state): State<Arc<AppState>>, |
| 82 | - Extension(namespace): Extension<Namespace>, |
| 83 | + Extension(_namespace): Extension<Namespace>, |
| 84 | Path(digest): Path<Digest>, |
| 85 | ) -> Result<Response, Error> { |
| 86 | let handle = state.oci.read_blob(&digest).await?; |
| 87 | diff --git a/src/axum/mod.rs b/src/axum/mod.rs |
| 88 | index 7eac269..41a30b4 100644 |
| 89 | --- a/src/axum/mod.rs |
| 90 | +++ b/src/axum/mod.rs |
| 91 | @@ -80,9 +80,8 @@ pub fn router(storage: &Storage) -> Router { |
| 92 | .route("/blobs/{digest}", get(handlers_blob::read)) |
| 93 | .route( |
| 94 | "/manifests/{digest}", |
| 95 | - put(handlers_manifest::write) |
| 96 | - .layer(DefaultBodyLimit::max(MAXIMUM_MANIFEST_SIZE)), |
| 97 | - ) |
| 98 | + put(handlers_manifest::write).layer(DefaultBodyLimit::max(MAXIMUM_MANIFEST_SIZE)), |
| 99 | + ).route("/manifests/{digest}", get(handlers_manifest::read)) |
| 100 | // // .route("/{name}/blobs/{digest}", head(crate::handlers::stat_blob)) |
| 101 | // // .route( |
| 102 | // // "/{name}/manifests/{reference}", |
| 103 | diff --git a/src/error.rs b/src/error.rs |
| 104 | index dcdec17..a55ec03 100644 |
| 105 | --- a/src/error.rs |
| 106 | +++ b/src/error.rs |
| 107 | @@ -38,7 +38,7 @@ pub enum Code { |
| 108 | |
| 109 | impl Display for Code { |
| 110 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 111 | - todo!() |
| 112 | + write!(f, "{:?}", self) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | diff --git a/src/oci_interface.rs b/src/oci_interface.rs |
| 117 | index 47222c8..b1a40e9 100644 |
| 118 | --- a/src/oci_interface.rs |
| 119 | +++ b/src/oci_interface.rs |
| 120 | @@ -1,4 +1,4 @@ |
| 121 | - use std::{pin::Pin, sync::Arc}; |
| 122 | + use std::pin::Pin; |
| 123 | |
| 124 | use bytes::Bytes; |
| 125 | use futures::{Stream, StreamExt}; |
| 126 | @@ -10,7 +10,7 @@ use uuid::Uuid; |
| 127 | |
| 128 | use crate::{ |
| 129 | Namespace, |
| 130 | - address::{Address, Blob, Manifest, TempBlob}, |
| 131 | + address::{Address, Blob, TempBlob}, |
| 132 | error::Error, |
| 133 | storage::{InnerStream, Storage, StorageIface}, |
| 134 | }; |
| 135 | diff --git a/src/storage.rs b/src/storage.rs |
| 136 | index a158341..a8dc90a 100644 |
| 137 | --- a/src/storage.rs |
| 138 | +++ b/src/storage.rs |
| 139 | @@ -1,8 +1,7 @@ |
| 140 | - use std::{io::Error as IoError, path::PathBuf, pin::Pin, sync::Arc}; |
| 141 | + use std::{io::Error as IoError, path::PathBuf, pin::Pin}; |
| 142 | |
| 143 | - use async_trait::async_trait; |
| 144 | use bytes::Bytes; |
| 145 | - use futures::{lock::Mutex, stream::BoxStream, Stream, StreamExt}; |
| 146 | + use futures::{Stream, stream::BoxStream}; |
| 147 | |
| 148 | use crate::{address::Address, storage_fs::FileSystem}; |
| 149 | |
| 150 | @@ -22,9 +21,7 @@ pub struct InnerStream { |
| 151 | |
| 152 | impl InnerStream { |
| 153 | pub fn new(stream: BoxStream<'static, Result<Bytes, std::io::Error>>) -> Self { |
| 154 | - InnerStream { |
| 155 | - stream |
| 156 | - } |
| 157 | + InnerStream { stream } |
| 158 | } |
| 159 | } |
| 160 |