|
|
|
@ -13,12 +13,24 @@ header("Access-Control-Allow-Credentials: true");
|
|
|
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
|
use Slim\App;
|
|
|
|
|
use SLim\Exception\HttpNotFoundException;
|
|
|
|
|
use gateway\UserGateway;
|
|
|
|
|
use Config\Token;
|
|
|
|
|
use Gateway\FileGateway;
|
|
|
|
|
|
|
|
|
|
return function (App $app) {
|
|
|
|
|
$app->options('/{routes:.+}', function ($request, $response, $args) {
|
|
|
|
|
return $response;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$app->add(function ($request, $handler) {
|
|
|
|
|
$response = $handler->handle($request);
|
|
|
|
|
return $response
|
|
|
|
|
->withHeader('Access-Control-Allow-Origin', '*')
|
|
|
|
|
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
|
|
|
|
|
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$app->get('/', function (Request $req, Response $res) {
|
|
|
|
|
$res->getBody()->write('SmartFit-API is working!');
|
|
|
|
|
return $res;
|
|
|
|
@ -227,4 +239,8 @@ return function (App $app) {
|
|
|
|
|
if($code === -1) return $res->withStatus(500);
|
|
|
|
|
return $res->withStatus(200);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$app->map(['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], '/{routes:.+}', function ($request, $response) {
|
|
|
|
|
throw new HttpNotFoundException($request);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|