2018-03-20 10:51:47 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require '../vendor/autoload.php';
|
|
|
|
|
|
|
|
use \Slim\Http\Request as Request;
|
|
|
|
use \Slim\Http\Response as Response;
|
|
|
|
|
|
|
|
// Load config
|
|
|
|
$config = require('../config/ConfigDefault.php');
|
|
|
|
|
2018-04-12 16:24:36 +02:00
|
|
|
// If no config exists load installer
|
|
|
|
if ($config === false) {
|
|
|
|
require('setup.php');
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:51:47 +01:00
|
|
|
// Prepare dependency container
|
|
|
|
$container = new \Slim\Container($config);
|
|
|
|
|
|
|
|
$container['logger'] = new \Services\Logger;
|
|
|
|
$container['db'] = new \Services\Database;
|
|
|
|
|
|
|
|
$container['notFoundHandler'] = new \Controllers\NotFound;
|
|
|
|
$container['notAllowedHandler'] = new \Controllers\NotAllowed;
|
|
|
|
|
|
|
|
// Create application
|
|
|
|
$app = new \Slim\App($container);
|
|
|
|
|
|
|
|
// Configure routing
|
|
|
|
$app->group('/v1', function () {
|
|
|
|
$this->post('/sessions', '\Controllers\Sessions:post');
|
|
|
|
|
2018-04-17 21:30:44 +02:00
|
|
|
$this->get('/remote/ip', '\Controllers\Remote:ip');
|
|
|
|
|
2018-03-20 10:51:47 +01:00
|
|
|
$this->group('', function () {
|
|
|
|
$this->delete('/sessions/{sessionId}', '\Controllers\Sessions:delete');
|
2018-03-21 16:51:14 +01:00
|
|
|
|
|
|
|
$this->get('/domains', '\Controllers\Domains:getList');
|
2018-03-24 14:48:49 +01:00
|
|
|
$this->post('/domains', '\Controllers\Domains:postNew');
|
2018-03-24 15:42:11 +01:00
|
|
|
$this->delete('/domains/{domainId}', '\Controllers\Domains:delete');
|
2018-03-24 16:37:35 +01:00
|
|
|
$this->get('/domains/{domainId}', '\Controllers\Domains:getSingle');
|
2018-03-24 21:05:38 +01:00
|
|
|
$this->put('/domains/{domainId}', '\Controllers\Domains:put');
|
2018-03-26 19:32:32 +02:00
|
|
|
|
|
|
|
$this->put('/domains/{domainId}/soa', '\Controllers\Domains:putSoa');
|
2018-03-26 20:14:45 +02:00
|
|
|
$this->get('/domains/{domainId}/soa', '\Controllers\Domains:getSoa');
|
2018-03-29 15:16:54 +02:00
|
|
|
|
|
|
|
$this->get('/records', '\Controllers\Records:getList');
|
2018-03-30 14:02:32 +02:00
|
|
|
$this->post('/records', '\Controllers\Records:postNew');
|
|
|
|
$this->delete('/records/{recordId}', '\Controllers\Records:delete');
|
|
|
|
$this->get('/records/{recordId}', '\Controllers\Records:getSingle');
|
|
|
|
$this->put('/records/{recordId}', '\Controllers\Records:put');
|
2018-03-31 12:59:12 +02:00
|
|
|
|
|
|
|
$this->get('/records/{recordId}/credentials', '\Controllers\Credentials:getList');
|
2018-03-31 14:59:45 +02:00
|
|
|
$this->post('/records/{recordId}/credentials', '\Controllers\Credentials:postNew');
|
2018-03-31 15:29:31 +02:00
|
|
|
$this->delete('/records/{recordId}/credentials/{credentialId}', '\Controllers\Credentials:delete');
|
2018-03-31 17:13:47 +02:00
|
|
|
$this->get('/records/{recordId}/credentials/{credentialId}', '\Controllers\Credentials:getSingle');
|
2018-04-01 16:05:24 +02:00
|
|
|
$this->put('/records/{recordId}/credentials/{credentialId}', '\Controllers\Credentials:put');
|
2018-04-01 19:52:00 +02:00
|
|
|
|
2018-04-05 16:23:55 +02:00
|
|
|
$this->get('/users', '\Controllers\Users:getList');
|
2018-04-06 09:48:17 +02:00
|
|
|
$this->post('/users', '\Controllers\Users:postNew');
|
|
|
|
$this->delete('/users/{user}', '\Controllers\Users:delete');
|
|
|
|
$this->get('/users/{user}', '\Controllers\Users:getSingle');
|
|
|
|
$this->put('/users/{user}', '\Controllers\Users:put');
|
2018-04-05 16:23:55 +02:00
|
|
|
|
2018-04-01 19:52:00 +02:00
|
|
|
$this->get('/users/{user}/permissions', '\Controllers\Permissions:getList');
|
2018-04-01 21:03:39 +02:00
|
|
|
$this->post('/users/{user}/permissions', '\Controllers\Permissions:postNew');
|
2018-04-01 21:20:53 +02:00
|
|
|
$this->delete('/users/{user}/permissions/{domainId}', '\Controllers\Permissions:delete');
|
2018-03-20 10:51:47 +01:00
|
|
|
})->add('\Middlewares\Authentication');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add global middlewares
|
|
|
|
$app->add('\Middlewares\LogRequests');
|
|
|
|
$app->add('\Middlewares\RejectEmptyBody');
|
2018-04-17 21:30:44 +02:00
|
|
|
$app->add('\Middlewares\ClientIp');
|
2018-03-20 10:51:47 +01:00
|
|
|
|
|
|
|
// Run application
|
|
|
|
$app->run();
|