Files
spa-api/app/Providers/RouteServiceProvider.php

53 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace App\Providers;
2014-08-11 10:13:20 -05:00
2020-08-27 13:36:32 -05:00
use Illuminate\Cache\RateLimiting\Limit;
2014-09-30 21:13:58 -05:00
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
2020-08-27 13:36:32 -05:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
2019-09-10 17:26:00 +02:00
use Illuminate\Support\Facades\Route;
2014-08-11 10:13:20 -05:00
2015-02-22 20:47:03 -06:00
class RouteServiceProvider extends ServiceProvider
{
2019-12-10 08:59:27 -06:00
/**
* The path to the "home" route for your application.
*
2020-07-14 14:10:07 -05:00
* This is used by Laravel authentication to redirect users after login.
2020-06-24 12:47:56 -05:00
*
2019-12-10 08:59:27 -06:00
* @var string
*/
public const HOME = '/home';
2015-02-22 20:47:03 -06:00
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
2016-07-11 15:44:50 -05:00
public function boot()
2015-02-22 20:47:03 -06:00
{
2020-08-27 13:36:32 -05:00
$this->configureRateLimiting();
2020-07-14 14:00:47 -05:00
$this->routes(function () {
Route::middleware('api')
->prefix('api')
2020-07-14 14:00:47 -05:00
->group(base_path('routes/api.php'));
2020-09-11 08:29:38 -05:00
Route::middleware('web')
->group(base_path('routes/web.php'));
2020-07-14 14:00:47 -05:00
});
2015-02-22 20:47:03 -06:00
}
2020-08-27 13:36:32 -05:00
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
2020-08-27 13:36:32 -05:00
});
}
}