Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3341021
D13619.id44914.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13619.id44914.diff
View Options
diff --git a/services/blob/src/http/handlers/holders.rs b/services/blob/src/http/handlers/holders.rs
--- a/services/blob/src/http/handlers/holders.rs
+++ b/services/blob/src/http/handlers/holders.rs
@@ -1,5 +1,6 @@
-use actix_web::error::ErrorBadRequest;
+use actix_web::error::{ErrorBadRequest, ErrorForbidden};
use actix_web::{web, HttpResponse};
+use comm_lib::auth::AuthorizationCredential;
use serde::{Deserialize, Serialize};
use tracing::{info, instrument, trace, warn};
@@ -128,6 +129,36 @@
Ok(HttpResponse::Ok().json(web::Json(response)))
}
+#[derive(Deserialize)]
+pub struct HoldersQueryUrlParams {
+ prefix: String,
+}
+
+#[derive(Serialize)]
+pub struct HoldersQueryResponse {
+ items: Vec<BlobHashAndHolder>,
+}
+
+#[instrument(name = "query_holders", skip_all)]
+pub async fn query_holders_handler(
+ service: web::Data<BlobService>,
+ query: web::Query<HoldersQueryUrlParams>,
+ requesting_identity: AuthorizationCredential,
+) -> actix_web::Result<HttpResponse> {
+ match requesting_identity {
+ AuthorizationCredential::ServicesToken(_) => (),
+ _ => {
+ return Err(ErrorForbidden(
+ "This endpoint can only be called by other services",
+ ));
+ }
+ };
+ let HoldersQueryUrlParams { prefix } = query.into_inner();
+ let items = service.query_indexed_holders(prefix).await?;
+ let response = HoldersQueryResponse { items };
+ Ok(HttpResponse::Ok().json(web::Json(response)))
+}
+
/**
* Returns `HTTP 400 Bad Request` if one or more blob hashes or holders
* have invalid format. See [`comm_lib::tools::is_valid_identifier`] for
diff --git a/services/blob/src/http/mod.rs b/services/blob/src/http/mod.rs
--- a/services/blob/src/http/mod.rs
+++ b/services/blob/src/http/mod.rs
@@ -48,6 +48,7 @@
.service(
web::resource("/holders")
.wrap(auth_middleware)
+ .route(web::get().to(handlers::holders::query_holders_handler))
.route(web::post().to(handlers::holders::assign_holders_handler))
.route(web::delete().to(handlers::holders::remove_holders_handler)),
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 10:18 PM (16 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2565938
Default Alt Text
D13619.id44914.diff (2 KB)
Attached To
Mode
D13619: [blob] Add endpoint to query holders by prefix
Attached
Detach File
Event Timeline
Log In to Comment