|
|
|
<?php
|
|
|
|
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
|
|
|
//error_reporting(E_ALL);
|
|
|
|
ini_set('display_errors', 0);
|
|
|
|
|
|
|
|
use app\controllers\QueueController;
|
|
|
|
use app\controllers\CallController;
|
|
|
|
use app\controllers\AuthController;
|
|
|
|
use app\middleware\AuthMiddleware;
|
|
|
|
use app\controllers\MeetController;
|
|
|
|
|
|
|
|
use Slim\Factory\AppFactory;
|
|
|
|
use Slim\Routing\RouteCollectorProxy;
|
|
|
|
use Tuupola\Middleware\CorsMiddleware;
|
|
|
|
|
|
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
header('Access-Control-Allow-Credentials: true');
|
|
|
|
header("Access-Control-Allow-Methods: HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS");
|
|
|
|
header("Access-Control-Allow-Headers: X-API-KEY, Origin, ngrok-skip-browser-warning, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization");
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
|
|
/*if ($method == "OPTIONS") {
|
|
|
|
echo "teste OK";
|
|
|
|
// header("HTTP/1.1 200 OK");
|
|
|
|
die();
|
|
|
|
}*/
|
|
|
|
|
|
|
|
$app = AppFactory::create();
|
|
|
|
$app->addRoutingMiddleware();
|
|
|
|
$app->add(new CorsMiddleware());
|
|
|
|
$app->addErrorMiddleware(false, true, true);
|
|
|
|
|
|
|
|
// Define app routes
|
|
|
|
$app->get('/api/v2/teste', function () {
|
|
|
|
echo "teste OK";
|
|
|
|
});
|
|
|
|
|
|
|
|
$app->group('/api/v2', AuthController::route());
|
|
|
|
$app->group('/api/v2/meet', MeetController::route());
|
|
|
|
|
|
|
|
$app->group('/api/v2', function (RouteCollectorProxy $group) {
|
|
|
|
$group->group('/call', CallController::route());
|
|
|
|
$group->group('/queue', QueueController::route());
|
|
|
|
})->add(new AuthMiddleware);
|
|
|
|
|
|
|
|
// Middleware de Fallback
|
|
|
|
try {
|
|
|
|
$app->run();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
die(json_encode(array("status" => "failed", "message" => "This action is not allowed")));
|
|
|
|
}
|