Changed some stuff about networking

This commit is contained in:
Johannes Wendel
2019-10-28 16:56:51 +01:00
parent a177b2a254
commit e5c8e6affc

View File

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