mirror of
https://github.com/easychen/pushdeer.git
synced 2024-11-14 22:39:27 +08:00
22 lines
447 B
PHP
22 lines
447 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Middleware;
|
||
|
|
||
|
use Closure;
|
||
|
use Illuminate\Http\Request;
|
||
|
|
||
|
class JsonRequest
|
||
|
{
|
||
|
public function handle(Request $request, Closure $next)
|
||
|
{
|
||
|
if (in_array($request->method(), ['POST', 'PUT', 'PATCH'])
|
||
|
&& $request->isJson()
|
||
|
) {
|
||
|
$data = $request->json()->all();
|
||
|
$request->request->replace(is_array($data) ? $data : []);
|
||
|
}
|
||
|
|
||
|
return $next($request);
|
||
|
}
|
||
|
}
|