$app->post('/auth/', function () use($app, $session) { if (!isset($_POST['machineid']) || !isset($_POST['secret'])) { textResponse(403, 'Authentication failed'); } elseif (!$session->login($_POST['machineid'], $_POST['secret'])) { textResponse(403, 'Authentication failed'); } else { jsonResponse(200, array('sessionid' => $session->getSessionId())); } }); $app->get('/auth/', function () use($app) { textResponse(400, 'Only POST method allowed for authentication'); }); /* Jails - List all jails */ $app->get('/jails/', 'isAllowed', function () use($app) { $jails = new Jails(); jsonResponse(200, $jails->getJails()); }); /* Jails - List individual jail info */ $app->get('/jails/:jailname/', 'isAllowed', function ($jailname) use($app) { $jails = new Jails(); if (!$jails->exists($jailname)) { textResponse(404, 'Jail unknown'); } else { jsonResponse(200, $jails->getJail($jailname)); } }); /* Queues - info about a queue */ $app->get('/queues/:queuename/:jailname/', 'isAllowed', function ($queuename, $jailname) use($app) { $queue = new Queue($queuename, $jailname); if ($queue->exists()) { jsonResponse(200, $queue->getQueueInfo());