支付宝记账本
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.

30 lines
648 B

6 months ago
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Cache\RateLimiting\Limit;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\RateLimiter;
  6. use Illuminate\Support\ServiceProvider;
  7. class AppServiceProvider extends ServiceProvider
  8. {
  9. /**
  10. * Register any application services.
  11. */
  12. public function register(): void
  13. {
  14. //
  15. }
  16. /**
  17. * Bootstrap any application services.
  18. */
  19. public function boot(): void
  20. {
  21. RateLimiter::for('api', function (Request $request) {
  22. $key = $request->user()->id ?? $request->ip();
  23. return Limit::perSecond(10)->by($key);
  24. });
  25. }
  26. }