Skip to content

A free open source IT asset/license management system

Shift service providers

Laravel Shiftddc8b8648ba8
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index f52cdcae15..f7742a6b25 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -2,6 +2,9 @@
namespace App\Providers;
+use Illuminate\Support\Facades\RateLimiter;
+use Illuminate\Http\Request;
+use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
@@ -23,25 +26,19 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
- //
+ $this->configureRateLimiting();
- parent::boot();
- }
+ $this->routes(function () {
+ $this->mapApiRoutes();
- /**
- * Define the routes for the application.
- *
- * @return void
- */
- public function map()
- {
- $this->mapApiRoutes();
-
- $this->mapWebRoutes();
+ $this->mapWebRoutes();
- //
+ //
+ });
}
+
+
/**
* Define the "web" routes for the application.
*
@@ -85,4 +82,16 @@ class RouteServiceProvider extends ServiceProvider
require base_path('routes/api.php');
});
}
+
+ /**
+ * Configure the rate limiters for the application.
+ *
+ * @return void
+ */
+ protected function configureRateLimiting()
+ {
+ RateLimiter::for('api', function (Request $request) {
+ return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
+ });
+ }
}