This commit is contained in:
Default
2025-03-27 23:10:03 +08:00
parent 81b573c296
commit dd0d52f693
45 changed files with 2502 additions and 1279 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
use app\api\controller\Novel;
use app\api\controller\Statis;
use think\facade\Route;
Route::post("/publish", [Statis::class, 'publish'])
// ->middleware(\think\middleware\Throttle::class, [
// 'visit_rate' => '1/m',
// 'key' => '__CONTROLLER__/__ACTION__/__IP__',
// ])
->name('Statis@publish');
Route::get("/search", [Novel::class, 'search'])
// ->middleware(\think\middleware\Throttle::class, [
// 'visit_rate' => '1/m',
// 'key' => '__CONTROLLER__/__ACTION__/__IP__',
// ])
->name('Novel@search');;
Route::get("/test", [Statis::class, 'test'])
// ->middleware(\think\middleware\Throttle::class, [
// 'visit_rate' => '1/m',
// 'key' => '__CONTROLLER__/__ACTION__/__IP__',
// ])
->name('Statis@test');

View File

@@ -0,0 +1,12 @@
<?php
use think\middleware\Throttle;
use think\Response;
return [
'prefix' => 'api:throttle_',
'visit_method' => ["GET", "POST", "PUT", "DELETE", "HEAD"],
'visit_fail_response' => function (Throttle $throttle, $request, $wait_seconds) {
return Response::create('抱歉,请求过于频繁, 请 ' . $wait_seconds . ' 秒后重新操作 。')->code(429);
},
];