diff --git a/route.php b/route.php index f2efd14..79e467e 100644 --- a/route.php +++ b/route.php @@ -344,6 +344,22 @@ class route return $this->map ($route, $function); } + /** Allow multiple methods to execute the function if the route is + corresponding to the URL. + Ex. : $app->multi("get,post,put,delete", '/hello/{name}', function ($name) { + echo "Hello, $name"; + }); + @param string $methods The allowed methods, separated by commas (,) + @param string $route Route to check with the URL + @param function $function Function to be executed if the route match */ + public function multi ($methods, $route, $function) + { + foreach (explode (",", $methods) as $method) + { + $this->$method ($route, $function); + } + } + /** Do the mapping between the url and the route : call the function if thereis a match @param string $route Route to check with the URL