Added "minimal" API request for requesting minimal responses only.
This commit is contained in:
parent
22467d603e
commit
bf180a2a35
1 changed files with 25 additions and 19 deletions
|
@ -483,10 +483,8 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
}
|
||||
#endif
|
||||
/*LTS-END*/
|
||||
//sent current configuration, no matter if it was changed or not
|
||||
Response["config"] = Controller::Storage["config"];
|
||||
Response["config"]["version"] = PACKAGE_VERSION;
|
||||
/*LTS-START*/
|
||||
if (!Request.isMember("minimal") || Request.isMember("streams") || Request.isMember("addstream") || Request.isMember("deletestream")){
|
||||
if (!Request.isMember("streams") && (Request.isMember("addstream") || Request.isMember("deletestream"))){
|
||||
Response["streams"]["incomplete list"] = 1ll;
|
||||
if (Request.isMember("addstream")){
|
||||
|
@ -497,14 +495,19 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
}
|
||||
}
|
||||
}else{
|
||||
/*LTS-END*/
|
||||
Response["streams"] = Controller::Storage["streams"];
|
||||
}//LTS
|
||||
}
|
||||
}
|
||||
//sent current configuration, if not minimal or was changed/requested
|
||||
if (!Request.isMember("minimal") || Response.isMember("config")){
|
||||
Response["config"] = Controller::Storage["config"];
|
||||
Response["config"]["version"] = PACKAGE_VERSION;
|
||||
//add required data to the current unix time to the config, for syncing reasons
|
||||
Response["config"]["time"] = Util::epoch();
|
||||
if ( !Response["config"].isMember("serverid")){
|
||||
Response["config"]["serverid"] = "";
|
||||
}
|
||||
}
|
||||
//sent any available logs and statistics
|
||||
///
|
||||
/// \api
|
||||
|
@ -521,14 +524,17 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
/// ~~~~~~~~~~~~~~~
|
||||
/// It's possible to clear the stored logs by sending an empty `"clearstatlogs"` request.
|
||||
///
|
||||
{
|
||||
if (Request.isMember("clearstatlogs") || !Request.isMember("minimal")){
|
||||
tthread::lock_guard<tthread::mutex> guard(logMutex);
|
||||
if (!Request.isMember("minimal")){
|
||||
Response["log"] = Controller::Storage["log"];
|
||||
}
|
||||
//clear log if requested
|
||||
if (Request.isMember("clearstatlogs")){
|
||||
Controller::Storage["log"].null();
|
||||
}
|
||||
}
|
||||
/*LTS-END*/
|
||||
if (Request.isMember("clients")){
|
||||
if (Request["clients"].isArray()){
|
||||
for (unsigned int i = 0; i < Request["clients"].size(); ++i){
|
||||
|
|
Loading…
Add table
Reference in a new issue