addRoutingMiddleware(); /** * Add Error Handling Middleware * * @param bool $displayErrorDetails -> Should be set to false in production * @param bool $logErrors -> Parameter is passed to the default ErrorHandler * @param bool $logErrorDetails -> Display error details in error log */ $errorMiddleware = $app->addErrorMiddleware(true, true, true); try { $app->get('/', function (Request $request, Response $response) { $parameters = $request->getQueryParams(); $method = $parameters['method']; unset($parameters['method']); $response->getBody()->write($method); $listGateway = array("\\Gateway\\GatewayForm", "\\Gateway\\GatewayKeyword", "\\Gateway\\GatewayQuestion"); foreach ($listGateway as $gateway) // Pour chaque Gateway { if (method_exists($gateway, $method)) { $response->getBody()->write((new $gateway)->$method($parameters)); // Si oui, on appelle cette fonction } } return $response->withHeader('Content-type', 'application/json'); }); }catch (TypeError $t){ echo "Error, wrong parameters key, or no parameters write : ".$t->getMessage(); } // Run app $app->run(); }catch (HttpNotFoundException $e) { echo "Error, not Found : " . $e->getMessage(); }