mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-18 10:51:07 +02:00
yhook: send valide error/ok responses; allow error message
Origin commit data
------------------
Branch: ni/coolstream
Commit: 57cc01978b
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-02-20 (Sat, 20 Feb 2016)
Origin message was:
------------------
- yhook: send valide error/ok responses; allow error message
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -538,3 +538,44 @@ std::string CyhookHandler::outNext() {
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CyhookHandler::SendOk() {
|
||||
std::string result = "";
|
||||
switch (outType) {
|
||||
case xml:
|
||||
result = "<success>true</success>";
|
||||
break;
|
||||
case json:
|
||||
result = "{\"success\": \"true\"}";
|
||||
break;
|
||||
default:
|
||||
result = "ok";
|
||||
break;
|
||||
}
|
||||
Write(result);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CyhookHandler::SendError(std::string error) {
|
||||
std::string result = "";
|
||||
switch (outType) {
|
||||
case xml:
|
||||
if (error.empty())
|
||||
result = "<success>false</success>";
|
||||
else
|
||||
result = "<success>false<error>" + error + "</error></success>";
|
||||
break;
|
||||
case json:
|
||||
if (error.empty())
|
||||
result = "{\"success\": \"false\"}";
|
||||
else
|
||||
result = "{\"success\": \"false\", \"error\":{\"text\": \"" + error + "\"}}";
|
||||
break;
|
||||
default:
|
||||
if (error.empty())
|
||||
result = "error";
|
||||
else
|
||||
result = "error=" + error;
|
||||
break;
|
||||
}
|
||||
Write(result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user