jonnybarnes.uk/app/Providers/RouteServiceProvider.php

57 lines
1.4 KiB
PHP
Raw Normal View History

2016-05-19 15:01:28 +01:00
<?php
namespace App\Providers;
2020-10-17 17:15:06 +01:00
use Illuminate\Cache\RateLimiting\Limit;
2016-05-19 15:01:28 +01:00
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
2020-10-17 17:15:06 +01:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
2019-10-19 15:34:49 +01:00
use Illuminate\Support\Facades\Route;
2016-05-19 15:01:28 +01:00
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
2020-10-17 17:15:06 +01:00
* @var string|null
2016-05-19 15:01:28 +01:00
*/
2020-10-17 17:15:06 +01:00
// protected $namespace = 'App\Http\Controllers';
2016-05-19 15:01:28 +01:00
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
2016-09-06 16:40:39 +01:00
public function boot()
2016-05-19 15:01:28 +01:00
{
2020-10-17 17:15:06 +01:00
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
2016-05-19 15:01:28 +01:00
}
/**
2020-10-17 17:15:06 +01:00
* Configure the rate limiters for the application.
2016-09-06 16:40:39 +01:00
*
* @return void
2022-05-14 17:44:14 +01:00
*
* @codeCoverageIgnore
2016-09-06 16:40:39 +01:00
*/
2020-10-17 17:15:06 +01:00
protected function configureRateLimiting()
2016-05-19 15:01:28 +01:00
{
2020-10-17 17:15:06 +01:00
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60);
});
2016-05-19 15:01:28 +01:00
}
}