diff options
Diffstat (limited to 'rotord/src/rotord.cpp')
| -rwxr-xr-x | rotord/src/rotord.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp index 600462c..928e07e 100755 --- a/rotord/src/rotord.cpp +++ b/rotord/src/rotord.cpp @@ -16,7 +16,6 @@ void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe std::ostream& ostr = response.send(); - ostr << "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; //this is the mysterious extra header ostr << content; } @@ -101,23 +100,25 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS } } else if (command[0]=="listnodes") { - XML.pushTag("rotor"); - if (request.getMethod()=="GET") { - Node_factory factory; - factory.list_nodes(XML); - status=HTTPResponse::HTTP_OK; - } if (command.size()>1){ if (command[1]=="json") { - string content="{\ - title: 'Lights Down @Rotor'',\ - audio: 'filename'',\ - id:,\ - type: 'patchBay',\ - nodeDefinitions: []\ - }"; - - return new RenderContextHandler(content, status); + Json::Value root; + Json::StyledWriter writer; + //root["title"]="Lights Down @Rotor"; + //root["audio"]="filename"; + root["nodeslist"]=Json::arrayValue; + Node_factory factory; + factory.list_nodes(root); + string content = writer.write(root); + return new RenderContextHandler(content, status); + } + } + else { + XML.pushTag("rotor"); + if (request.getMethod()=="GET") { + Node_factory factory; + factory.list_nodes(XML); + status=HTTPResponse::HTTP_OK; } } } @@ -227,9 +228,11 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS logger.error("ERROR: Empty request"); XML.addValue("error","Empty request"); } + string header="<?xml version='1.0' encoding='ISO-8859-1'?>\n"; string content; XML.copyXmlToString(content); - return new RenderContextHandler(content, status); + header+=content; + return new RenderContextHandler(header, status); } |
