Skip to content

Commit

Permalink
Update per AMWA-TV/is-13#21
Browse files Browse the repository at this point in the history
  • Loading branch information
garethsb committed May 23, 2023
1 parent 674bb36 commit 1723709
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Development/nmos/annotation_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<slog::severities::info>(gate, SLOG_FLF) << "Returning " << count << " matching " << resourceType;

Expand Down

0 comments on commit 1723709

Please sign in to comment.