From d29a12794815311c46518ede1a94e00198ee5efe Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 23 Feb 2012 09:09:00 -0600 Subject: [PATCH] allow multiple request methods for uri. --- laravel/routing/router.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/laravel/routing/router.php b/laravel/routing/router.php index a311923f..d266fa56 100644 --- a/laravel/routing/router.php +++ b/laravel/routing/router.php @@ -39,7 +39,13 @@ class Router { * * @var array */ - public static $fallback = array(); + public static $fallback = array( + 'GET' => array(), + 'POST' => array(), + 'PUT' => array(), + 'DELETE' => array(), + 'HEAD' => array(), + ); /** * The current attributes being shared by routes. @@ -87,7 +93,7 @@ class Router { * * @var array */ - public static $methods = array('GET', 'POST', 'PUT', 'DELETE'); + public static $methods = array('GET', 'POST', 'PUT', 'DELETE', 'HEAD'); /** * Register a HTTPS route with the router. @@ -168,6 +174,19 @@ public static function register($method, $route, $action) { if (is_string($route)) $route = explode(', ', $route); + // If the developer is registering multiple request methods to handle + // the URI, we'll spin through each method and register the route + // for each of them along with each URI. + if (is_array($method)) + { + foreach ($method as $http) + { + static::register($http, $route, $action); + } + + return; + } + foreach ((array) $route as $uri) { // If the URI begins with a splat, we'll call the universal method, which