Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
26.67% |
4 / 15 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
RouteServiceProvider | |
26.67% |
4 / 15 |
|
0.00% |
0 / 3 |
10.31 | |
0.00% |
0 / 1 |
boot | |
57.14% |
4 / 7 |
|
0.00% |
0 / 1 |
2.31 | |||
mapWebRoutes | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
mapApiRoutes | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Providers; |
4 | |
5 | use Illuminate\Cache\RateLimiting\Limit; |
6 | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
7 | use Illuminate\Http\Request; |
8 | use Illuminate\Support\Facades\RateLimiter; |
9 | use Illuminate\Support\Facades\Route; |
10 | |
11 | class RouteServiceProvider extends ServiceProvider |
12 | { |
13 | /** |
14 | * The path to the "home" route for your application. |
15 | * |
16 | * @var string |
17 | */ |
18 | public const HOME = '/home'; |
19 | |
20 | /** |
21 | * Define your route model bindings, pattern filters, etc. |
22 | */ |
23 | public function boot(): void |
24 | { |
25 | RateLimiter::for('api', function (Request $request) { |
26 | return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); |
27 | }); |
28 | |
29 | $this->routes(function () { |
30 | $this->mapApiRoutes(); |
31 | |
32 | $this->mapWebRoutes(); |
33 | }); |
34 | // |
35 | } |
36 | |
37 | /** |
38 | * Define the "web" routes for the application. |
39 | * |
40 | * These routes all receive session state, CSRF protection, etc. |
41 | */ |
42 | protected function mapWebRoutes(): void |
43 | { |
44 | Route::middleware('web') |
45 | ->group(base_path('routes/web.php')); |
46 | } |
47 | |
48 | /** |
49 | * Define the "api" routes for the application. |
50 | * |
51 | * These routes are typically stateless. |
52 | */ |
53 | protected function mapApiRoutes(): void |
54 | { |
55 | Route::prefix('romeo/api/v1') |
56 | ->middleware('api') |
57 | ->group(base_path('routes/api-v1.php')); |
58 | |
59 | Route::prefix('romeo/api/v2') |
60 | ->middleware('api') |
61 | ->group(base_path('routes/api-v2.php')); |
62 | } |
63 | } |