diff options
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Router.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/system/core/Router.php b/system/core/Router.php index 0f7278ae6..9071f84b7 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -345,15 +345,42 @@ class CI_Router { // Turn the segment array into a URI string $uri = implode('/', $this->uri->segments); + // Get HTTP verb + $http_verb = strtolower($_SERVER['REQUEST_METHOD']); + // Is there a literal match? If so we're done - if (isset($this->routes[$uri]) && is_string($this->routes[$uri])) + if (isset($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 route format is using http verb + if (is_array($val)) + { + // Does the http verb match? + if (isset($val[$http_verb])) + { + $val = $val[$http_verb]; + } + // No match, skip to next rule + else + { + continue; + } + } + // Convert wildcards to RegEx $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key); |