forge/routes/web.php
Refringe 7e1c66f250
Download Count Review
Reviewed the download count PR work and made some changes:
- Updated the download link route to include the mod's slug for easier identification.
- Moved rate limiter from the route middleware (the entire controller) to just the show method in the controller.
- Created a ModVersionPolicy that the controller can check against.
- Moves download increment logic into the model.
- Defers the call to the download increment logic (now run in the background)
- Updated the route to have a name, and the downloadUrl methods to build the URL dynamically using the route name.
- Wrote some tests to check URL building, download counting, and rate limiting.

# Conflicts:
#	app/Http/Controllers/ModVersionController.php
#	app/Providers/AppServiceProvider.php
2024-09-25 17:04:46 -04:00

39 lines
1.2 KiB
PHP

<?php
use App\Http\Controllers\ModController;
use App\Http\Controllers\ModVersionController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
Route::middleware(['auth.banned'])->group(function () {
Route::get('/', function () {
return view('home');
})->name('home');
Route::controller(ModController::class)->group(function () {
Route::get('/mods', 'index')->name('mods');
Route::get('/mod/{mod}/{slug}', 'show')->where(['mod' => '[0-9]+'])->name('mod.show');
});
Route::controller(ModVersionController::class)->group(function () {
Route::get('/mod/download/{mod}/{slug}/{version}', 'show')
->where([
'mod' => '[0-9]+',
'slug' => '[a-z0-9-]+',
])
->name('mod.version.download');
});
Route::controller(UserController::class)->group(function () {
Route::get('/user/{user}/{username}', 'show')->where(['user' => '[0-9]+'])->name('user.show');
});
Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
Route::get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
});
});