summaryrefslogtreecommitdiff
path: root/src/lib/http_server.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-11-30 23:01:00 +0100
committerCarl Hetherington <cth@carlh.net>2026-04-25 12:55:25 +0200
commit151a4983bb8017fca789b7cf394e30e195cfade5 (patch)
tree34e462ec3c2bbf8d39a71bf51c25e6ef9d992a21 /src/lib/http_server.cc
parent5af132d913cd0dd4ef709556b91d906bbf01a558 (diff)
Add content GET endpoint.
Diffstat (limited to 'src/lib/http_server.cc')
-rw-r--r--src/lib/http_server.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc
index 1797b025c..4d1823bc4 100644
--- a/src/lib/http_server.cc
+++ b/src/lib/http_server.cc
@@ -24,6 +24,7 @@
#include "dcpomatic_socket.h"
#include "http_server.h"
#include "show_playlist.h"
+#include "show_playlist_content_store.h"
#include "show_playlist_list.h"
#include "util.h"
#include "variant.h"
@@ -161,6 +162,30 @@ HTTPServer::get(string const& url)
auto response = Response(200, json.dump());
response.set_type(Response::Type::JSON);
return response;
+ } else if (url == "/api/v1/content") {
+ nlohmann::json json;
+ for (auto i: ShowPlaylistContentStore::instance()->all()) {
+ /* XXX: converting to JSON this way feels a bit grotty */
+ json.push_back(ShowPlaylistEntry(i, {}).as_json());
+ }
+ 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;