mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 08:53:43 +08:00
parent
dfef23e50c
commit
136a07361f
|
@ -16,13 +16,15 @@ use Zend\Stratigility\MiddlewareInterface;
|
||||||
|
|
||||||
class FakeHttpMethods implements MiddlewareInterface
|
class FakeHttpMethods implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
|
const HEADER_NAME = 'x-fake-http-method';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function __invoke(Request $request, Response $response, callable $out = null)
|
public function __invoke(Request $request, Response $response, callable $out = null)
|
||||||
{
|
{
|
||||||
if ($request->getMethod() === 'POST' && $request->hasHeader('x-http-method')) {
|
if ($request->getMethod() === 'POST' && $request->hasHeader(self::HEADER_NAME)) {
|
||||||
$fakeMethod = $request->getHeaderLine('x-http-method');
|
$fakeMethod = $request->getHeaderLine(self::HEADER_NAME);
|
||||||
|
|
||||||
$request = $request->withMethod(strtoupper($fakeMethod));
|
$request = $request->withMethod(strtoupper($fakeMethod));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user