ldc-gen-game-web/app/Providers/RouteServiceProvider.php

71 lines
1.8 KiB
PHP
Raw Normal View History

2020-10-21 15:26:21 +02:00
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
2020-10-21 15:26:21 +02:00
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
2020-10-21 15:26:21 +02:00
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = null;
2020-10-21 15:26:21 +02:00
/**
* The path to the "home" route for your application.
*
* @var string
*/
2020-10-29 15:40:23 +01:00
public const HOME = '/';
2020-10-21 15:26:21 +02:00
/**
* Define your route model bindings, pattern filters, etc.
2020-10-21 15:26:21 +02:00
*
* @return void
*/
public function boot()
2020-10-21 15:26:21 +02:00
{
$this->configureRateLimiting();
2020-10-21 15:26:21 +02:00
$this->routes(function () {
Route::middleware('web')
2020-10-21 15:26:21 +02:00
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Route::middleware('web')
2022-01-10 15:47:22 +01:00
->namespace($this->namespace)
->group(base_path('routes/web-bo.php'));
Route::middleware('web')
2022-01-10 15:47:22 +01:00
->namespace($this->namespace)
->group(base_path('routes/web-re7.php'));
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
});
2020-10-21 15:26:21 +02:00
}
/**
* Configure the rate limiters for the application.
2020-10-21 15:26:21 +02:00
*
* @return void
*/
protected function configureRateLimiting()
2020-10-21 15:26:21 +02:00
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
2020-10-21 15:26:21 +02:00
}
}