mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-09-25 11:44:15 +00:00
More endpoints
This commit is contained in:
+45
-1
@@ -2,12 +2,13 @@ use crate::state::AppState;
|
||||
use axum::body::Bytes;
|
||||
use axum::{
|
||||
Json,
|
||||
extract::State,
|
||||
extract::{Query, State},
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use cid::Cid;
|
||||
use multihash::Multihash;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use sha2::{Digest, Sha256};
|
||||
use sqlx::Row;
|
||||
@@ -136,3 +137,46 @@ pub async fn upload_blob(
|
||||
}))
|
||||
.into_response()
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct ListMissingBlobsParams {
|
||||
pub limit: Option<i64>,
|
||||
pub cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RecordBlob {
|
||||
pub cid: String,
|
||||
pub record_uri: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ListMissingBlobsOutput {
|
||||
pub cursor: Option<String>,
|
||||
pub blobs: Vec<RecordBlob>,
|
||||
}
|
||||
|
||||
pub async fn list_missing_blobs(
|
||||
State(_state): State<AppState>,
|
||||
headers: axum::http::HeaderMap,
|
||||
Query(_params): Query<ListMissingBlobsParams>,
|
||||
) -> Response {
|
||||
let auth_header = headers.get("Authorization");
|
||||
if auth_header.is_none() {
|
||||
return (
|
||||
StatusCode::UNAUTHORIZED,
|
||||
Json(json!({"error": "AuthenticationRequired"})),
|
||||
)
|
||||
.into_response();
|
||||
}
|
||||
|
||||
(
|
||||
StatusCode::OK,
|
||||
Json(ListMissingBlobsOutput {
|
||||
cursor: None,
|
||||
blobs: vec![],
|
||||
}),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ pub mod blob;
|
||||
pub mod meta;
|
||||
pub mod record;
|
||||
|
||||
pub use blob::upload_blob;
|
||||
pub use blob::{list_missing_blobs, upload_blob};
|
||||
pub use meta::describe_repo;
|
||||
pub use record::{apply_writes, create_record, delete_record, get_record, list_records, put_record};
|
||||
|
||||
Reference in New Issue
Block a user