From 831dd7ad472780b18a44c9be20fa5299611b628d Mon Sep 17 00:00:00 2001 From: kj Date: Tue, 11 Aug 2020 18:52:35 -0400 Subject: [PATCH] Fix error on middleware set for DELETE method. --- config.php | 2 -- src/Libs/Router.php | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config.php b/config.php index 28ae170..e9f4ef7 100644 --- a/config.php +++ b/config.php @@ -8,5 +8,3 @@ define('dbpass', ''); define('ROOT_DIR', __DIR__); ?> - - diff --git a/src/Libs/Router.php b/src/Libs/Router.php index 9d2c9b5..f1d7fa5 100644 --- a/src/Libs/Router.php +++ b/src/Libs/Router.php @@ -158,6 +158,19 @@ class Router { static::$last = ['post', count(static::$post)-1]; 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) { static::$put[] = static::parse($path, $callback); @@ -179,14 +192,13 @@ class Router { */ public static function delete($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(); } /* * Devuelve el URI path actual */ - public static function URIPath() { return preg_replace('/'.preg_quote(static::baseURI(), '/').'/', '/', strtok($_SERVER['REQUEST_URI'], '?'), 1);