allow multiple request methods for uri.
This commit is contained in:
parent
f624a6849f
commit
d29a127948
|
@ -39,7 +39,13 @@ class Router {
|
||||||
*
|
*
|
||||||
* @var array
|
* @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.
|
* The current attributes being shared by routes.
|
||||||
|
@ -87,7 +93,7 @@ class Router {
|
||||||
*
|
*
|
||||||
* @var array
|
* @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.
|
* 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 (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)
|
foreach ((array) $route as $uri)
|
||||||
{
|
{
|
||||||
// If the URI begins with a splat, we'll call the universal method, which
|
// If the URI begins with a splat, we'll call the universal method, which
|
||||||
|
|
Loading…
Reference in New Issue