|
11 | 11 | class RouteServiceProvider extends ServiceProvider
|
12 | 12 | {
|
13 | 13 | /**
|
14 |
| - * The path to the "home" route for your application. |
| 14 | + * The path to your application's "home" route. |
15 | 15 | *
|
16 |
| - * This is used by Laravel authentication to redirect users after login. |
| 16 | + * Typically, users are redirected here after authentication. |
17 | 17 | *
|
18 | 18 | * @var string
|
19 | 19 | */
|
20 | 20 | public const HOME = '/home';
|
21 | 21 |
|
22 | 22 | /**
|
23 |
| - * The controller namespace for the application. |
24 |
| - * |
25 |
| - * When present, controller route declarations will automatically be prefixed with this namespace. |
26 |
| - * |
27 |
| - * @var string|null |
28 |
| - */ |
29 |
| - // protected $namespace = 'App\\Http\\Controllers'; |
30 |
| - |
31 |
| - /** |
32 |
| - * Define your route model bindings, pattern filters, etc. |
33 |
| - * |
34 |
| - * @return void |
| 23 | + * Define your route model bindings, pattern filters, and other route configuration. |
35 | 24 | */
|
36 |
| - public function boot() |
| 25 | + public function boot(): void |
37 | 26 | {
|
38 |
| - $this->configureRateLimiting(); |
| 27 | + RateLimiter::for('api', function (Request $request) { |
| 28 | + return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); |
| 29 | + }); |
39 | 30 |
|
40 | 31 | $this->routes(function () {
|
41 |
| - Route::prefix('api') |
42 |
| - ->middleware('api') |
43 |
| - ->namespace($this->namespace) |
| 32 | + Route::middleware('api') |
| 33 | + ->prefix('api') |
44 | 34 | ->group(base_path('routes/api.php'));
|
45 | 35 |
|
46 | 36 | Route::middleware('web')
|
47 |
| - ->namespace($this->namespace) |
48 | 37 | ->group(base_path('routes/web.php'));
|
49 | 38 | });
|
50 | 39 | }
|
51 |
| - |
52 |
| - /** |
53 |
| - * Configure the rate limiters for the application. |
54 |
| - * |
55 |
| - * @return void |
56 |
| - */ |
57 |
| - protected function configureRateLimiting() |
58 |
| - { |
59 |
| - RateLimiter::for('api', function (Request $request) { |
60 |
| - return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); |
61 |
| - }); |
62 |
| - } |
63 | 40 | }
|
0 commit comments