35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
use think\facade\Route;
|
|
|
|
Route::group('v1', function() {
|
|
// 接口授权
|
|
Route::post('authorize', 'v1.Authorize/token');
|
|
|
|
// 接口授权后才能访问
|
|
Route::group(function(){
|
|
// 获取产品列表
|
|
Route::get('products', 'v1.Product/list');
|
|
Route::group('product', function() {
|
|
// 获取产品信息
|
|
Route::get(':id', 'v1.Product/detail');
|
|
|
|
// 获取产品分类
|
|
Route::get('categories', 'v1.Product/categories');
|
|
});
|
|
|
|
// 获取新闻动态
|
|
Route::get('news', 'v1.News/list');
|
|
Route::group('news', function() {
|
|
// 获取新闻详情
|
|
Route::get(':id', 'v1.News/detail');
|
|
});
|
|
})
|
|
->middleware(\app\openapi\middleware\Auth::class);
|
|
})
|
|
->middleware(\think\middleware\Throttle::class, [
|
|
'visit_rate' => '5/m',
|
|
'visit_fail_response' => function (\think\middleware\Throttle $throttle, \think\Request $request, int $wait_seconds) {
|
|
return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429);
|
|
},
|
|
]); |