Browse Source

Add support for X-HTTP-Method-Override header

tags/3.1.0
Mike Koch 2 years ago
parent
commit
3aea482c3c
1 changed files with 16 additions and 1 deletions
  1. 16
    1
      api/Link.php

+ 16
- 1
api/Link.php View File

@@ -39,7 +39,7 @@ class Link
}

self::$routes = $routes;
$method = strtolower($_SERVER['REQUEST_METHOD']);
$method = self::getRequestMethod();
$path = '/';
$handler = null;
$matched = array();
@@ -108,6 +108,21 @@ class Link
}
}

private static function getRequestMethod() {
$headers = getallheaders();

$uppercaseHeaders = array();
foreach ($headers as $header => $value) {
$uppercaseHeaders[strtoupper($header)] = $value;
}

if (isset($uppercaseHeaders['X-HTTP-METHOD-OVERRIDE'])) {
return $uppercaseHeaders['X-HTTP-METHOD-OVERRIDE'];
}

return $_SERVER['REQUEST_METHOD'];
}

/**
* Static function that helps you generate links effortlessly and pass parameters to them, thus enabling to generate dynamic links
*

Loading…
Cancel
Save