mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
Rearranged code
This commit is contained in:
parent
542f5518a6
commit
7496a0bab2
@ -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()),
|
||||
|
Loading…
Reference in New Issue
Block a user