mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
30 lines
713 B
PHP
30 lines
713 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Validation\UnauthorizedException;
|
|
|
|
class Platform
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
$platform = nexus()->getPlatform();
|
|
if (empty($platform)) {
|
|
throw new \InvalidArgumentException("Require platform header.");
|
|
}
|
|
if (!nexus()->isPlatformValid()) {
|
|
throw new \InvalidArgumentException("Invalid platform: " . $platform);
|
|
}
|
|
return $next($request);
|
|
}
|
|
}
|