diff options
author | GDmac <grdalenoort@gmail.com> | 2013-11-11 13:15:18 +0100 |
---|---|---|
committer | GDmac <grdalenoort@gmail.com> | 2013-11-11 13:15:18 +0100 |
commit | 5d9b03b022bbc95c3c57830cc4cc27c39c7a59be (patch) | |
tree | 9f03a708761e0ac429a0ed080d2eef593e4694a0 /system/core/Router.php | |
parent | 01e9fb1d6aab8e513a9ebd786e9abff74d8b63ca (diff) | |
parent | c761a206def7714d18623d46b05adc2bbeedce21 (diff) |
Merge branch 'develop' of https://github.com/EllisLab/CodeIgniter into develop
Diffstat (limited to 'system/core/Router.php')
-rw-r--r-- | system/core/Router.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/system/core/Router.php b/system/core/Router.php index 0f7278ae6..d467d60fd 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -345,15 +345,40 @@ class CI_Router { // Turn the segment array into a URI string $uri = implode('/', $this->uri->segments); + // Get HTTP verb + $http_verb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli'; + // 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 a 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)) + { + if (isset($val[$http_verb])) + { + $val = $val[$http_verb]; + } + else + { + continue; + } + } + // Convert wildcards to RegEx $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key); |