Skip to content

Commit 50f1633

Browse files
committed
v1.6.13 - Configurable throttle
1 parent 91d2c56 commit 50f1633

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fleetbase/core-api",
3-
"version": "1.6.12",
3+
"version": "1.6.13",
44
"description": "Core Framework and Resources for Fleetbase API",
55
"keywords": [
66
"fleetbase",
@@ -21,6 +21,7 @@
2121
"php": "^8.0",
2222
"aws/aws-sdk-php-laravel": "^3.7",
2323
"fleetbase/laravel-mysql-spatial": "^1.0.2",
24+
"fleetbase/countries": "^0.8.3",
2425
"fleetbase/twilio": "^5.0.1",
2526
"giggsey/libphonenumber-for-php": "^8.13",
2627
"google/apiclient": "^2.18",
@@ -44,7 +45,6 @@
4445
"maatwebsite/excel": "^3.1",
4546
"phpoffice/phpspreadsheet": "^1.28",
4647
"phrity/websocket": "^1.7",
47-
"pragmarx/countries": "^0.8.2",
4848
"sentry/sentry-laravel": "*",
4949
"spatie/laravel-activitylog": "^4.7",
5050
"spatie/laravel-google-cloud-storage": "^2.2",

config/api.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
<?php
22

3-
return [];
3+
return [
4+
'throttle' => [
5+
'max_attempts' => env('THROTTLE_REQUESTS_PER_MINUTE', 90),
6+
'decay_minutes' => env('THROTTLE_DECAY_MINUTES', 1),
7+
],
8+
];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Fleetbase\Http\Middleware;
4+
5+
use Illuminate\Routing\Middleware\ThrottleRequests as ThrottleRequestsMiddleware;
6+
use Closure;
7+
8+
class ThrottleRequests extends ThrottleRequestsMiddleware
9+
{
10+
public function handle($request, Closure $next, $maxAttempts = null, $decayMinutes = null, $prefix = '')
11+
{
12+
$maxAttempts = config('api.throttle.max_attempts', 90);
13+
$decayMinutes = config('api.throttle.decay_minutes', 1);
14+
15+
return parent::handle($request, $next, $maxAttempts, $decayMinutes, $prefix);
16+
}
17+
}

src/Providers/CoreServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CoreServiceProvider extends ServiceProvider
5757
\Fleetbase\Http\Middleware\TrackPresence::class,
5858
],
5959
'fleetbase.api' => [
60-
'throttle:80,1',
60+
\Fleetbase\Http\Middleware\ThrottleRequests::class,
6161
\Illuminate\Session\Middleware\StartSession::class,
6262
\Fleetbase\Http\Middleware\AuthenticateOnceWithBasicAuth::class,
6363
\Illuminate\Routing\Middleware\SubstituteBindings::class,

0 commit comments

Comments
 (0)