Skip to content

Commit

Permalink
Router now suppor other http method like DELETE, PUT, PATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
yourjhay committed May 18, 2020
1 parent 051731e commit e1168e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Simple/Routing/BaseRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static function match($url)
{
foreach(self::$routes as $route => $params){
if(preg_match($route, $url, $matches)){

foreach($matches as $key => $match){
if(is_string($key)){
$params[$key] = $match;
Expand Down Expand Up @@ -172,6 +173,9 @@ public static function dispatch($url)

if (preg_match('/action$/i', $action) == 0) {
$request = $_SERVER['REQUEST_METHOD'];
if(isset($_POST['_method'])){
$request = $_POST['_method'];
}
$user_request_method = strtoupper(self::$params['request_method']);
if($request === $user_request_method
|| $user_request_method === 'ANY'
Expand Down

0 comments on commit e1168e6

Please sign in to comment.