Files
orico-official-website/app/openapi/route/v1.php

43 lines
1.4 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')->when('id', 'number');
// 获取产品分类
Route::get('categories', 'v1.ProductCategory/list');
});
// 获取文章动态
Route::get('articles', 'v1.Article/list');
Route::group('article', function() {
// 获取文章详情
Route::get(':id', 'v1.Article/detail')->when('id', 'number');
// 获取文章分类
Route::get('categories', 'v1.ArticleCategory/list');
});
})
->middleware(\app\openapi\middleware\Auth::class);
})
->middleware(\think\middleware\Throttle::class, [
'prefix' => 'throttle_',
'visit_rate' => '5/m',
'key' => function($throttle, $request) {
return '__CONTROLLER__/__ACTION__/__IP__';
},
'visit_fail_response' => function (\think\middleware\Throttle $throttle, \think\Request $request, int $wait_seconds) {
return \think\Response::create('您的操作过于频繁, 请在 ' . $wait_seconds . ' 秒后再试。')->code(429);
},
])
->completeMatch(true);