mirror of
https://github.com/lsky-org/lsky-pro.git
synced 2025-01-09 04:19:32 +08:00
27 lines
520 B
PHP
27 lines
520 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Enums\ConfigKey;
|
|
use App\Http\Result;
|
|
use App\Utils;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CheckIsEnableApi
|
|
{
|
|
use Result;
|
|
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
if (! Utils::config(ConfigKey::IsEnableApi)) {
|
|
if ($request->expectsJson()) {
|
|
return $this->fail('管理员未启用 API')->setStatusCode(403);
|
|
}
|
|
abort(404);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|