feat(registry): expose release detail endpoint
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 22s

This commit is contained in:
faumaray committed 2026-12-03 23:55:09 +03:00
1 parent 7bd04718df
commit 3832ec1db4
6 files changed
+67 -2

No files matched your search

+41
View File
@@ -900,6 +900,47 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
"}\n");
}
// Release detail: GET /api/v1/packages/<name>/<version>
if (segs.size() == 5 && 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");
}
const auto &release = rit->second;
return HttpResponse::json(
200, "{\"name\":" + json_quote(pkg_name) + ",\"version\":" +
json_quote(release.version) + ",\"sha256\":" + json_quote(release.sha256) +
",\"size_bytes\":" + std::to_string(release.size_bytes) +
",\"yanked\":" + std::string{release.yanked ? "true" : "false"} +
",\"publisher\":" + json_quote(release.publisher) +
",\"published_epoch\":" + std::to_string(release.published_epoch) +
(release.signature.empty()
? std::string{}
: ",\"signature\":" + json_quote(release.signature)) +
(release.public_key.empty()
? std::string{}
: ",\"public_key\":" + json_quote(release.public_key)) +
",\"binaries\":" +
json_array(release.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"} + '}';
}) +
"}\n");
}
// Publish immutable release: PUT /api/v1/packages/<name>/<version>
if (segs.size() == 5 && req.method == "PUT") {
if (!principal) {