Files
lotteryLaravel/routes/api.php

55 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Http\Controllers\Api\V1\Admin\PingController as AdminPingController;
use App\Http\Controllers\Api\V1\HealthController;
use App\Http\Controllers\Api\V1\Player\MeController;
use App\Http\Controllers\Api\V1\Player\PingController as PlayerPingController;
use App\Http\Controllers\Api\V1\Wallet\WalletBalanceController;
use Illuminate\Support\Facades\Route;
/*
| Laravel 在 bootstrap 中为本文件自动加前缀 `api` + 中间件组 `api`,故实际 URL
| /api/v1/health
| /api/v1/player/...
| /api/v1/wallet/...
| /api/v1/admin/...
*/
Route::prefix('v1')->group(function (): void {
// 探活:无鉴权
Route::get('health', HealthController::class)->name('api.v1.health');
// 玩家前缀下:仅 ping 公开me 与 wallet/* 共用 lottery.player见下方大组
Route::prefix('player')
->name('api.v1.player.')
->group(function (): void {
Route::get('ping', PlayerPingController::class)->name('ping');
});
/*
| 已登录玩家PRD 把路径拆成 `/v1/player/*` 与 `/v1/wallet/*`,这里用同一中间件块避免重复写。
| 勿把 wallet 挂到 player 前缀下,否则会变成 /api/v1/player/wallet/...,与 PRD §10.1.1 不一致。
*/
Route::middleware('lottery.player')->group(function (): void {
Route::prefix('player')
->name('api.v1.player.')
->group(function (): void {
Route::get('me', MeController::class)->name('me');
});
Route::prefix('wallet')
->name('api.v1.wallet.')
->group(function (): void {
Route::get('balance', WalletBalanceController::class)->name('balance');
});
});
// 后台 APIlottery.admin 内预留 Sanctum / RBAC
Route::middleware('lottery.admin')
->prefix('admin')
->name('api.v1.admin.')
->group(function (): void {
Route::get('ping', AdminPingController::class)->name('ping');
});
});