Fix error on middleware set for DELETE method.

This commit is contained in:
kj 2020-08-11 18:52:35 -04:00
parent 8a46d9a3c9
commit 831dd7ad47
2 changed files with 14 additions and 4 deletions

View File

@ -8,5 +8,3 @@ define('dbpass', '');
define('ROOT_DIR', __DIR__); define('ROOT_DIR', __DIR__);
?> ?>

View File

@ -159,6 +159,19 @@ class Router {
return new static(); return new static();
} }
/*
* Define los routers para el método PUT.
*
* @param string $path
* URI con pseudovariables
*
* @param function $callback
* Función en formato Clase::Método que será llamada cuando la url y el método coincidan
*
* @return static
* Devuelve un enlace estático
*/
public static function put($path, $callback) { public static function put($path, $callback) {
static::$put[] = static::parse($path, $callback); static::$put[] = static::parse($path, $callback);
static::$last = ['put', count(static::$put)-1]; static::$last = ['put', count(static::$put)-1];
@ -179,14 +192,13 @@ class Router {
*/ */
public static function delete($path, $callback) { public static function delete($path, $callback) {
static::$delete[] = static::parse($path, $callback); static::$delete[] = static::parse($path, $callback);
static::$last = ['delete', count(static::$put)-1]; static::$last = ['delete', count(static::$delete)-1];
return new static(); return new static();
} }
/* /*
* Devuelve el URI path actual * Devuelve el URI path actual
*/ */
public static function URIPath() { public static function URIPath() {
return preg_replace('/'.preg_quote(static::baseURI(), '/').'/', return preg_replace('/'.preg_quote(static::baseURI(), '/').'/',
'/', strtok($_SERVER['REQUEST_URI'], '?'), 1); '/', strtok($_SERVER['REQUEST_URI'], '?'), 1);