feat(registry): add a binary-variant listing endpoint
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 24s

This commit is contained in:
faumaray committed 2026-12-03 23:18:41 +03:00
1 parent 349ec257f5
commit 8f68ec56e9
7 files changed
+77 -38

No files matched your search

+30
View File
@@ -1187,6 +1187,36 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
return resp;
}
// List binary variants: GET /api/v1/packages/<name>/<version>/binaries
if (segs.size() == 6 && segs[5] == "binaries" && req.method == "GET") {
const auto pit = packages_.find(pkg_name);
if (pit == packages_.end()) {
return HttpResponse::error_json(404, "not_found", "package not found");
}
if (!can_read_pkg(pit->second)) {
return HttpResponse::error_json(principal ? 403 : 401, "forbidden",
"private package requires authorization");
}
const auto rit = pit->second.releases.find(segs[4]);
if (rit == pit->second.releases.end()) {
return HttpResponse::error_json(404, "not_found", "release not found");
}
return HttpResponse::json(
200,
"{\"binaries\":" + json_array(rit->second.binaries, [](const auto &entry) {
const auto &b = entry.second;
return "{\"variant_id\":" + json_quote(b.variant_id) +
",\"sha256\":" + json_quote(b.sha256) +
",\"size_bytes\":" + std::to_string(b.size_bytes) +
",\"yanked\":" + std::string{b.yanked ? "true" : "false"} +
(b.signature.empty() ? std::string{}
: ",\"signature\":" + json_quote(b.signature)) +
(b.public_key.empty() ? std::string{}
: ",\"public_key\":" + json_quote(b.public_key)) +
'}';
}) + "}\n");
}
// Yank/unyank a binary variant:
// POST /api/v1/packages/<name>/<version>/binaries/<variant>/yank
if (segs.size() == 8 && segs[5] == "binaries" && segs[7] == "yank" &&