Add support for X-HTTP-Method-Override header
This commit is contained in:
parent
a4836f1142
commit
3aea482c3c
17
api/Link.php
17
api/Link.php
@ -39,7 +39,7 @@ class Link
|
|||||||
}
|
}
|
||||||
|
|
||||||
self::$routes = $routes;
|
self::$routes = $routes;
|
||||||
$method = strtolower($_SERVER['REQUEST_METHOD']);
|
$method = self::getRequestMethod();
|
||||||
$path = '/';
|
$path = '/';
|
||||||
$handler = null;
|
$handler = null;
|
||||||
$matched = array();
|
$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
|
* Static function that helps you generate links effortlessly and pass parameters to them, thus enabling to generate dynamic links
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user