diff --git a/examples/8-KafkaToHttpServer.cxx b/examples/8-KafkaToHttpServer.cxx index f4e01b20..cc1fe456 100644 --- a/examples/8-KafkaToHttpServer.cxx +++ b/examples/8-KafkaToHttpServer.cxx @@ -46,6 +46,23 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) { } beast::ostream(response.body()) << jsonPrefix << envsJson << jsonSuffix << '\n'; }); + connection->addCallback("SHOW+TAG+VALUES+FROM+envs", + [](http::request& /*request*/, http::response& response) { + std::string jsonPrefix = R"({"results": [{"statement_id": 0, "series": [{"name": "env_active", "columns": ["key", "value"], "values": [)"; + std::string jsonSuffix = R"(]}]}]})"; + response.set(http::field::content_type, "application/json"); + const std::lock_guard lock(gEnvAccess); + std::string envsJson; + for (int i = 0; i < gActiveEnvs.activeruns_size(); i++) { + envsJson += "[\"env\", \"" + std::to_string(gActiveEnvs.activeruns(i).environmentid()) + "\"],"; + } + if (!envsJson.empty()) { + envsJson.pop_back(); + } else { + envsJson += "[\"env\", \"0\"]"; + } + beast::ostream(response.body()) << jsonPrefix << envsJson << jsonSuffix << '\n'; + }); connection->addCallback("SHOW+TAG+VALUES+FROM+detectors", [](http::request& request, http::response& response) { std::string jsonPrefix = R"({"results": [{"statement_id": 0, "series": [{"name": "detectors", "columns": ["key", "value"], "values": [)";