From 172370925a441434f20bf6dab8abc877b411ca37 Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley Date: Tue, 23 May 2023 12:44:01 +0100 Subject: [PATCH] Update per https://github.com/AMWA-TV/is-13/pull/21 --- Development/nmos/annotation_api.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Development/nmos/annotation_api.cpp b/Development/nmos/annotation_api.cpp index 0f71a3e45..9857cff90 100644 --- a/Development/nmos/annotation_api.cpp +++ b/Development/nmos/annotation_api.cpp @@ -248,13 +248,28 @@ namespace nmos size_t count = 0; - set_reply(res, status_codes::OK, - web::json::serialize_array(resources - | boost::adaptors::filtered(match) - | boost::adaptors::transformed( - [&count](const nmos::resources::value_type& resource) { ++count; return nmos::make_annotation_response(resource); } - )), - web::http::details::mime_types::application_json); + // experimental extension, to support human-readable HTML rendering of NMOS responses + if (experimental::details::is_html_response_preferred(req, web::http::details::mime_types::application_json)) + { + set_reply(res, status_codes::OK, + web::json::serialize_array(resources + | boost::adaptors::filtered(match) + | boost::adaptors::transformed( + [&count, &req](const nmos::resource& resource) { ++count; return experimental::details::make_html_response_a_tag(resource.id + U("/"), req); } + )), + web::http::details::mime_types::application_json); + } + else + { + set_reply(res, status_codes::OK, + web::json::serialize_array(resources + | boost::adaptors::filtered(match) + | boost::adaptors::transformed( + [&count](const nmos::resource& resource) { ++count; return value(resource.id + U("/")); } + ) + ), + web::http::details::mime_types::application_json); + } slog::log(gate, SLOG_FLF) << "Returning " << count << " matching " << resourceType;