summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-12-20 23:09:04 +0100
committerCarl Hetherington <cth@carlh.net>2026-02-16 01:20:38 +0100
commite91ae40d666e44702e8f15fea72a158b96ff66c8 (patch)
tree634d35ea85ffbb3d2f7bf743c32c92d52499d7c6
parentbb28fab565509893cb02e637f2b721851dad33f0 (diff)
Add content GET endpoint.
-rw-r--r--src/lib/http_server.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc
index 594f581d9..cdb1981ca 100644
--- a/src/lib/http_server.cc
+++ b/src/lib/http_server.cc
@@ -122,6 +122,21 @@ HTTPServer::get(string const& url)
auto response = Response(200, json.dump());
response.set_type(Response::Type::JSON);
return response;
+ } else if (boost::algorithm::starts_with(url, "/api/v1/content/")) {
+ vector<string> parts;
+ boost::algorithm::split(parts, url, boost::is_any_of("/"));
+ if (parts.size() != 5) {
+ return Response::ERROR_404;
+ }
+ auto content = ShowPlaylistContentStore::instance()->get(parts[4]);
+ if (!content) {
+ return Response::ERROR_404;
+ }
+ /* XXX: converting to JSON this way feels a bit grotty */
+ auto json = ShowPlaylistEntry(content, {}).as_json();
+ auto response = Response(200, json.dump());
+ response.set_type(Response::Type::JSON);
+ return response;
} else {
LOG_HTTP("404 {}", url);
return Response::ERROR_404;