ldc-web/app/Providers/RouteServiceProvider.php

61 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2020-04-09 13:05:23 +02:00
<?php
namespace App\Providers;
2022-09-21 11:17:58 +00:00
use Illuminate\Cache\RateLimiting\Limit;
2020-04-09 13:05:23 +02:00
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
2022-09-21 11:17:58 +00:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
2020-04-09 13:05:23 +02:00
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
2022-09-21 11:17:58 +00:00
* This is used by Laravel authentication to redirect users after login.
*
2020-04-09 13:05:23 +02:00
* @var string
*/
public const HOME = '/';
2020-04-09 13:05:23 +02:00
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
2022-09-21 11:17:58 +00:00
$this->configureRateLimiting();
2020-04-09 13:05:23 +02:00
2022-09-21 11:17:58 +00:00
$this->routes(function () {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web-bo.php'));
2020-04-09 13:05:23 +02:00
2022-09-21 11:17:58 +00:00
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web-fo.php'));
2020-04-09 13:05:23 +02:00
2022-09-21 11:17:58 +00:00
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
});
2020-04-09 13:05:23 +02:00
}
/**
2022-09-21 11:17:58 +00:00
* Configure the rate limiters for the application.
2020-04-09 13:05:23 +02:00
*
* @return void
*/
2022-09-21 11:17:58 +00:00
protected function configureRateLimiting()
2020-04-09 13:05:23 +02:00
{
2022-09-21 11:17:58 +00:00
RateLimiter::for('web', function (Request $request) {
return Limit::perMinute(150)->by(optional($request->user())->id ?: app('clientIp'));
});
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(150)->by(optional($request->user())->id ?: app('clientIp'));
});
2020-04-09 13:05:23 +02:00
}
}