diff --git a/spectrum_manager/src/APIServer.cpp b/spectrum_manager/src/APIServer.cpp index b23dc935..5ea6e831 100644 --- a/spectrum_manager/src/APIServer.cpp +++ b/spectrum_manager/src/APIServer.cpp @@ -78,12 +78,10 @@ void APIServer::send_ack(struct mg_connection *conn, bool error, const std::stri } void APIServer::serve_instances(Server *server, Server::session *session, struct mg_connection *conn, struct http_message *hm) { -// std::string jid = get_http_var(hm, "jid"); -// if (!jid.empty()) { -// serve_instance(conn, hm, jid); -// return; -// } - + // rapidjson stores const char* pointer to status, so we have to keep + // the std::string stored out of BOOST_FOREACH scope, otherwise the + // const char * returned by c_str() would be invalid during send_json. + std::vector statuses; std::vector list = show_list(m_config, false); Document json; @@ -101,7 +99,9 @@ void APIServer::serve_instances(Server *server, Server::session *session, struct if (status.empty()) { status = "Cannot get the instance status."; } - instance.AddMember("status", status.c_str(), json.GetAllocator()); + + statuses.push_back(status); + instance.AddMember("status", statuses.back().c_str(), json.GetAllocator()); bool running = true; if (status.find("Running") == std::string::npos) { diff --git a/spectrum_manager/src/server.cpp b/spectrum_manager/src/server.cpp index 27edfa71..dbb9e3b8 100644 --- a/spectrum_manager/src/server.cpp +++ b/spectrum_manager/src/server.cpp @@ -390,6 +390,7 @@ void Server::serve_logout(struct mg_connection *conn, struct http_message *hm) { } void Server::serve_oauth2(struct mg_connection *conn, struct http_message *hm) { +// http://slack.spectrum.im/oauth2/localhostxmpp?code=14830663267.19140123492.e7f78a836d&state=534ab3b6-8bf1-4974-8274-847df8490bc5 std::cout << "OAUTH2 handler\n"; }