summaryrefslogtreecommitdiffstats
path: root/system/core/Router.php
diff options
context:
space:
mode:
authorFatih Kalifa <fatih@pvey.es>2013-11-05 09:36:40 +0100
committerFatih Kalifa <fatih@pvey.es>2013-11-05 09:36:40 +0100
commit0b58b3cad456efc5ecce89f622876c6b715439c2 (patch)
tree1a67cdf87d5e3aa2c698ad392d9befd413719a43 /system/core/Router.php
parent442b50b0c78a8c630b139d3a9a30d3b731253565 (diff)
Fix HTTP Verb Routing Rules
Fix code style, removed (:any) rule in http verb to avoid confusion, and add proposed documentation and changelog
Diffstat (limited to 'system/core/Router.php')
-rw-r--r--system/core/Router.php32
1 files changed, 14 insertions, 18 deletions
diff --git a/system/core/Router.php b/system/core/Router.php
index 89d11afab..9071f84b7 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -349,38 +349,34 @@ class CI_Router {
$http_verb = strtolower($_SERVER['REQUEST_METHOD']);
// Is there a literal match? If so we're done
- if (isset($this->routes[$uri][$http_verb]))
+ if (isset($this->routes[$uri]))
{
- return $this->_set_request(explode('/', $this->routes[$uri][$http_verb]));
- }
- else if (isset($this->routes[$uri]['(:any)']))
- {
- return $this->_set_request(explode('/', $this->routes[$uri]['(:any)']));
- }
- // Fallback to default routing
- else if (isset($this->routes[$uri]) && is_string($this->routes[$uri]))
- {
- return $this->_set_request(explode('/', $this->routes[$uri]));
+ // Check default routes format
+ if (is_string($this->routes[$uri]))
+ {
+ return $this->_set_request(explode('/', $this->routes[$uri]));
+ }
+ // Is there any matching http verb?
+ elseif (is_array($this->routes[$uri]) && isset($this->routes[$uri][$http_verb]))
+ {
+ return $this->_set_request(explode('/', $this->routes[$uri][$http_verb]));
+ }
}
// Loop through the route array looking for wildcards
foreach ($this->routes as $key => $val)
{
- // Check if HTTP Verb is exist
+ // Check if route format is using http verb
if (is_array($val))
{
- // HTTP verb included in routes
+ // Does the http verb match?
if (isset($val[$http_verb]))
{
$val = $val[$http_verb];
}
- else if (isset($val['(:any)']))
- {
- $val = $val['(:any)'];
- }
+ // No match, skip to next rule
else
{
- // HTTP Verb not found
continue;
}
}