}; }; /** * */ $app = new \Slim\App($c); $app->add(new HandleCors()); $app->group('/api', function () use($app) { $app->group('/v1', function () use($app) { $app->add(new JsonResponse()); /** * */ $app->get('/catalog[/{table}]', function ($req, $res, $args) { $table = isset($args['table']) ? $args['table'] : null; $result = Store::catalog($table); if (!$result) { return $res->withStatus(404)->write(JsonHelper::fail('Tabella inesistente.')); } return $res->write(JsonHelper::success($result)); }); /** * */ $app->post('/autenticazione', function ($req, $res) { $body = $req->getParsedBody(); $codiceFiscale = isset($body['codice_fiscale']) ? $body['codice_fiscale'] : ''; $password = isset($body['password']) ? $body['password'] : ''; $result = Auth::authenticate($codiceFiscale, $password); if (!$result) { return $res->withStatus(403)->write(JsonHelper::fail('Codice Fiscale e/o Password errati.'));