You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 satır
1.7KB

  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Cache\RateLimiting\Limit;
  4. use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\RateLimiter;
  7. use Illuminate\Support\Facades\Route;
  8. class RouteServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * The path to the "home" route for your application.
  12. *
  13. * Typically, users are redirected here after authentication.
  14. *
  15. * @var string
  16. */
  17. public const HOME = '/home';
  18. /**
  19. * Define your route model bindings, pattern filters, and other route configuration.
  20. */
  21. public function boot(): void
  22. {
  23. $this->configureRateLimiting();
  24. $this->routes(function () {
  25. Route::middleware('web')
  26. ->prefix('api')
  27. ->group(base_path('routes/api.php'));
  28. Route::middleware('api')
  29. ->prefix('api-from-kintone')
  30. ->group(base_path('routes/apiFromKintone.php'));
  31. Route::middleware(['api', "fromHTICWeb"])
  32. ->prefix('api/ht-ic-web')
  33. ->group(base_path('routes/apiFromHTICWeb.php'));
  34. Route::middleware('web')
  35. ->group(base_path('routes/web.php'));
  36. });
  37. }
  38. /**
  39. * Configure the rate limiters for the application.
  40. */
  41. protected function configureRateLimiting(): void
  42. {
  43. RateLimiter::for('api', function (Request $request) {
  44. return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
  45. });
  46. RateLimiter::for('web', function (Request $request) {
  47. return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
  48. });
  49. }
  50. }