Skip to content

Instantly share code, notes, and snippets.

View lukaszmtw's full-sized avatar

Luke Oslizlo lukaszmtw

View GitHub Profile
@lukaszmtw
lukaszmtw / ThrottleRequestsPerRoute.php
Last active March 21, 2020 16:14
I noticed that the default throttling middleware in Laravel doesn't throttle requests per route so I made my own variation of the ThrottleRequests middleware that works per route.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Cache\RateLimiter;
use Illuminate\Http\Exceptions\ThrottleRequestsException;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
use RuntimeException;
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Cache\RateLimiter;
use Illuminate\Http\Exceptions\ThrottleRequestsException;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
use RuntimeException;