mirror of
https://github.com/flarum/core.git
synced 2025-10-19 10:46:06 +02:00
Extract another middleware from API routing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Flarum\Api\Request as ApiRequest;
|
||||
use Flarum\Api\Request;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
$action = function ($class) {
|
||||
@@ -8,14 +8,8 @@ $action = function ($class) {
|
||||
$action = $this->app->make($class);
|
||||
$actor = $this->app->make('Flarum\Support\Actor');
|
||||
|
||||
if (str_contains($httpRequest->getHeaderLine('content-type'), 'application/vnd.api+json')) {
|
||||
$input = json_decode($httpRequest->getBody(), true);
|
||||
} else {
|
||||
$input = $httpRequest->getAttributes();
|
||||
}
|
||||
$input = array_merge($input, $routeParams);
|
||||
|
||||
$request = new ApiRequest($input, $actor, $httpRequest);
|
||||
$input = array_merge($httpRequest->getAttributes(), $routeParams);
|
||||
$request = new Request($input, $actor, $httpRequest);
|
||||
|
||||
return $action->handle($request);
|
||||
};
|
||||
|
Reference in New Issue
Block a user