方法覆盖中间件

方法覆盖中间件使您能够使用X-Http-Method-Override请求标头或请求正文参数_METHOD来覆盖传入请求的方法。中间件应该放在添加路由中间件之后。

用法

<?php
use Slim\Factory\AppFactory;
use Slim\Middleware\MethodOverrideMiddleware;

require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

// Add RoutingMiddleware before we add the MethodOverrideMiddleware so the method is overridden before routing is done
$app->addRoutingMiddleware();

// Add MethodOverride middleware
$methodOverrideMiddleware = new MethodOverrideMiddleware();
$app->add($methodOverrideMiddleware);

// ...

$app->run();