LSurl::add_handler: fix handling all params in case of multiple patterns

This commit is contained in:
Benjamin Renard 2021-08-18 12:29:50 +02:00
parent 2fa20316bc
commit 2b71bba8db

View file

@ -33,21 +33,20 @@ class LSurl extends LSlog_staticLoggerClass {
/* /*
* Configured URL patterns : * Configured URL patterns :
* *
* array ( * Example :
* '[URL pattern]' => '[handler]',
* [...]
* )
*
* Example :
* *
* array ( * array (
* '|get/(?P<name>[a-zA-Z0-9]+)$|' => array ( * '|get/(?P<name>[a-zA-Z0-9]+)$|' => array (
* 'handler' => 'get', * 'handler' => 'get',
* 'authenticated' => true, * 'authenticated' => true,
* 'api_mode' => false,
* 'methods' => array('GET'),
* ), * ),
* '|get/all$|' => => array ( * '|get/all$|' => => array (
* 'handler' => 'get_all', * 'handler' => 'get_all',
* 'authenticated' => true, * 'authenticated' => true,
* 'api_mode' => false,
* 'methods' => array('GET', 'POST'),
* ), * ),
* ) * )
* *
@ -72,10 +71,10 @@ class LSurl extends LSlog_staticLoggerClass {
if (is_array($pattern)) { if (is_array($pattern)) {
if (is_null($handler)) if (is_null($handler))
foreach($pattern as $p => $h) foreach($pattern as $p => $h)
self :: add_handler($p, $h, $override, $api_mode, $methods); self :: add_handler($p, $h, $authenticated, $override, $api_mode, $methods);
else else
foreach($pattern as $p) foreach($pattern as $p)
self :: add_handler($p, $handler, $override, $api_mode, $methods); self :: add_handler($p, $handler, $authenticated, $override, $api_mode, $methods);
} }
else { else {
if (!isset(self :: $patterns[$pattern])) { if (!isset(self :: $patterns[$pattern])) {