Changed some stuff about networking

This commit is contained in:
Johannes Wendel
2019-10-28 16:56:51 +01:00
parent 6084b01c7c
commit 585dbe0811

View File

@@ -72,7 +72,6 @@ void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
}
response.setContentType("text/json");
response.setStatus(HTTPServerResponse::HTTP_OK);
try
{
@@ -80,6 +79,7 @@ void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
if(json_response)
{
response.setStatus(HTTPServerResponse::HTTP_OK);
std::ostream& ostr = response.send();
json_response->stringify(ostr);
}
@@ -129,9 +129,9 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseRequest(const std
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSolenoid(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
Poco::JSON::Object response;
response.set("solenoids", getItemArray(this->output_driver->get_solenoids()) );
return response;
}
@@ -154,14 +154,14 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSolenoid(const st
throw new Poco::NotFoundException("No action with name \"" + action + "\" on solenoids!");
}
return {};
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseLamp(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
Poco::JSON::Object response;
response.set("lamps", getItemArray(this->output_driver->get_lamps()) );
return response;
}
@@ -188,7 +188,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseLamp(const std::s
throw new Poco::NotFoundException("No action with name \"" + action + "\" on lamps!");
}
return {};
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSound(const std::string& item_name, const std::string& action)
@@ -223,9 +223,9 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSound(const std::
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseDisplay(const std::string& item_name, const std::string& action, const std::string& score)
{
Poco::JSON::Object response;
if(item_name == "")
{
Poco::JSON::Object response;
response.set("displays", this->output_driver->get_displays());
return response;
}
@@ -258,14 +258,14 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseDisplay(const std
throw new Poco::NotFoundException("No Action with name \"" + action + "\" on sounds!");
}
return {};
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseFlipper(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
Poco::JSON::Object response;
response.set("flippers", getItemArray(this->output_driver->get_flippers()) );
return response;
}
@@ -292,7 +292,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseFlipper(const std
throw new Poco::NotFoundException("No action with name \"" + action + "\" on flippers!");
}
return {};
return response;
}
std::vector<std::string> OutputRequestHandler::getPathSegments(Poco::URI uri)