1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +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::Value root;
Response response;
std::string command;
if (reader.parse(request, root, false))
{
response.message = "Request is no valid JSON";
response.code = Response::Code::JsonError;
l(response.message, LogLevel::warning);
} else {
std::string command;
goto out;
}
try {
command = getJsonOrFail<std::string>(root, "command");
}
@ -84,7 +86,6 @@ static void session(tcp::socket &&sock)
response.message = "Received unknown command " + command;
l(response.message, LogLevel::warning);
}
}
out:
sock.write_some(boost::asio::buffer(response.toJson()),