Change the method param to a args in URL
continuous-integration/drone/push Build is passing Details

master
dorian.hodin 2 years ago
parent a9405c433d
commit f62015ebdb

@ -9,8 +9,8 @@ use Throwable;
class TypeErrorMethod extends HttpSpecializedException {
protected $code = 400;
protected string $title = "Method query params is not specified";
protected $message = "Bad Parameters, The API need a 'method' query params in URL. Exemple :'http://url?method=getSomething'";
protected string $title = "Method is not specified";
protected $message = "Bad Parameters, The API need a 'method' args in URL. Exemple :'http://url/method=getSomething'";
public function __construct(ServerRequestInterface $request,?Throwable $previous = null)
{

@ -29,14 +29,14 @@ $errorMiddleware = $app->addErrorMiddleware(true, true, true);
/**
* Add a route for the API
*/
$app->get('/', function (Request $request, Response $response){
$parameters = $request->getQueryParams();
if (empty($parameters['method'])){
throw new TypeErrorMethod($request);
}else{
$method = $parameters['method'];
}
unset($parameters['method']);
});
$app->get('/{method}', function (Request $request, Response $response, array $args) {
$parameters = $request->getQueryParams();
$method = $args['method'];
$listGateway = array("\\Gateway\\GatewayForm", "\\Gateway\\GatewayKeyword", "\\Gateway\\GatewayQuestion");
$ok = false;
foreach ($listGateway as $gateway){

Loading…
Cancel
Save