1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 18:34:25 +01:00

Rearranged code

This commit is contained in:
Ralf Ramsauer 2015-09-22 21:55:31 +02:00
parent 542f5518a6
commit 7496a0bab2

View File

@ -57,14 +57,16 @@ static void session(tcp::socket &&sock)
Json::Reader reader; Json::Reader reader;
Json::Value root; Json::Value root;
Response response; Response response;
std::string command;
if (reader.parse(request, root, false)) if (reader.parse(request, root, false))
{ {
response.message = "Request is no valid JSON"; response.message = "Request is no valid JSON";
response.code = Response::Code::JsonError; response.code = Response::Code::JsonError;
l(response.message, LogLevel::warning); l(response.message, LogLevel::warning);
} else { goto out;
std::string command; }
try { try {
command = getJsonOrFail<std::string>(root, "command"); command = getJsonOrFail<std::string>(root, "command");
} }
@ -84,7 +86,6 @@ static void session(tcp::socket &&sock)
response.message = "Received unknown command " + command; response.message = "Received unknown command " + command;
l(response.message, LogLevel::warning); l(response.message, LogLevel::warning);
} }
}
out: out:
sock.write_some(boost::asio::buffer(response.toJson()), sock.write_some(boost::asio::buffer(response.toJson()),