Commit a8aa6eb1 authored by Frederic Logier's avatar Frederic Logier
Browse files

return a json on HTTP API error

parent 0b923c74
<div id="wrapper" class="wat-cf">
<div id="main">
<div class="block" id="block-tables">
<div class="content">
<h2 class="title">New app</h2>
<div class="inner">
<form action="/admin/createapp" method="post" class="form">
<div class="columns wat-cf">
<div class="column left">
<div class="group">
<label class="label">App name</label>
<input type="text" class="text_field" name="appname">
</div>
</div>
<div class="column right">
<div class="group">
<?=users?>
</div>
</div>
</div>
<div class="group navform wat-cf">
<button class="button" type="submit">
<img src="/staticfile/images/tick.png" alt="Save"> Save
</button>
<span class="text_button_padding">or</span>
<a class="text_button_padding link_button" href="#header">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div id="wrapper" class="wat-cf">
<div id="main">
<div class="block" id="block-tables">
<div class="secondary-navigation">
<ul class="wat-cf">
<li class="first"><a href="/admin/users">Users</a></li>
<li class="active"><a href="/admin/apps">Apps</a></li>
<li><a href="/admin/nodes">Nodes</a></li>
<li><a href="/admin/workflows">Workflows</a></li>
<li><a href="/admin/workers">Workers</a></li>
<li><a href="/admin/sessions">Sessions</a></li>
<li><a href="/admin/payloads">Payloads</a></li>
<li><a href="/admin/lost_pushpull_payloads">Lost pushpull payloads</a></li>
</ul>
</div>
<div class="content">
<h2 class="title">Apps : <?=data_count?></h2>
<div class="inner">
<form action="/admin/deleteapp" method="post" class="form">
<table class="table">
<tbody><tr>
<th class="first"><input type="checkbox" class="checkbox toggle"></th>
<th>appname</th>
<th>uuid</th>
<th>owner</th>
<th class="last">&nbsp;</th>
</tr>
<?=data?>
</tbody></table>
<div class="actions-bar wat-cf">
<div class="actions">
<a href="/admin/createapp"><button class="button" type="button">
<img src="/staticfile/images/tick.png" alt="New"> New
</button></a>
<button class="button" type="submit">
<img src="/staticfile/images/cross.png" alt="Delete"> Delete
</button>
</div>
<div class="pagination">
<span class="disabled prev_page">« Previous</span><span class="current">1</span><a rel="next" href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a><a href="#">6</a><a href="#">7</a><a href="#">8</a><a href="#">9</a><a href="#">10</a><a href="#">11</a><a rel="next" class="next_page" href="#">Next »</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
......@@ -406,7 +406,7 @@ void Api_payload::receive_http_payload()
{
case HTTP_METHOD:
// check METHOD
if (request.size() == 0) bodyMessage ="header METHOD is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "METHOD is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -432,7 +432,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check URI
if (request.size() == 0) bodyMessage ="header URI is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "URI is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -445,7 +445,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-user-token
if (request.size() == 0) bodyMessage ="header X-user-token is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-user-token is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -463,7 +463,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-node-uuid
if (request.size() == 0) bodyMessage ="header X-node-uuid is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-node-uuid is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -476,7 +476,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-node-password
if (request.size() == 0) bodyMessage ="header X-node-password is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-node-password is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -535,7 +535,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-workflow-uuid
if (request.size() == 0) bodyMessage ="header X-workflow-uuid is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-workflow-uuid is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -562,7 +562,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-payload-type
if (request.size() == 0) bodyMessage ="header X-payload-type is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-payload-type is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -574,7 +574,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-payload-mime
if (request.size() == 0) bodyMessage ="header X-payload-mime is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-payload-mime is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -586,7 +586,7 @@ void Api_payload::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-payload-action
if (request.size() == 0) bodyMessage ="header X-payload-action is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-payload-action is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -732,7 +732,7 @@ void Api_node::receive_http_payload()
{
bodyMessage = buildResponse("error", "auth");
}
else if (zerogw["X-node-name"].isEmpty()) bodyMessage = "X-node-name empty";
else if (zerogw["X-node-name"].isEmpty()) bodyMessage = buildResponse("error", "header", "X-node-name is empty");
else
{
QUuid node_uuid = QUuid::createUuid();
......@@ -981,7 +981,7 @@ void Api_user::receive_http_payload()
else if (zerogw["X-admin-token"].isEmpty())
{
bodyMessage ="X-admin-token is empty";
bodyMessage = buildResponse("error", "header", "X-admin-token is empty");
}
else
{
......@@ -1127,7 +1127,7 @@ void Api_session::receive_http_payload()
{
case HTTP_METHOD:
// check METHOD
if (request.size() == 0) bodyMessage ="header METHOD is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "METHOD is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1142,7 +1142,7 @@ void Api_session::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check URI
if (request.size() == 0) bodyMessage ="header URI is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "URI is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1154,7 +1154,7 @@ void Api_session::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-user-token
if (request.size() == 0) bodyMessage ="header X-user-token is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-user-token is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1172,7 +1172,7 @@ void Api_session::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-node-uuid
if (request.size() == 0) bodyMessage ="header X-session-uuid is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-session-uuid is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1302,7 +1302,7 @@ void Api_app::receive_http_payload()
{
case HTTP_METHOD:
// check METHOD
if (request.size() == 0) bodyMessage ="header METHOD is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "METHOD is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1317,7 +1317,7 @@ void Api_app::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check URI
if (request.size() == 0) bodyMessage ="header URI is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "URI is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1330,7 +1330,7 @@ void Api_app::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-user-token
if (request.size() == 0) bodyMessage ="header X-user-token is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-user-token is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1444,7 +1444,7 @@ void Api_ftp::receive_http_payload()
{
case HTTP_METHOD:
// check METHOD
if (request.size() == 0) bodyMessage ="header METHOD is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "METHOD is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1459,7 +1459,7 @@ void Api_ftp::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check URI
if (request.size() == 0) bodyMessage ="header URI is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "URI is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1474,7 +1474,7 @@ void Api_ftp::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-user-email
if (request.size() == 0) bodyMessage ="header X-user-email is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-user-email is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......@@ -1486,7 +1486,7 @@ void Api_ftp::receive_http_payload()
if (!bodyMessage.isEmpty()) break;
// Check X-user-password
if (request.size() == 0) bodyMessage ="header X-user-password is empty";
if (request.size() == 0) bodyMessage = buildResponse("error", "header", "X-user-password is empty");
else
{
data_from_zerogw = QString::fromAscii((char*)request.data(), request.size());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment