1
0
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:
Franz Liedke
2015-05-27 01:48:04 +02:00
parent 3ff230dc26
commit 343da9fc40
2 changed files with 27 additions and 9 deletions

View File

@@ -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);
};