class Illuminate / Routing / Middleware / ThrottleRequests

ThrottleRequests

Uses

Properties

protected

$limiter RateLimiter

The rate limiter instance.

Default: null
protected static

$shouldHashKeys bool

Indicates if the rate limiter keys should be hashed.

Default: true

Methods

public

__construct ( RateLimiter $limiter ) : void

Create a new request throttler.

Parameters

public static

using ( $name ) : string

Specify the named rate limiter to use for the middleware.

Parameters

  • $name string
public static

with ( $maxAttempts , $decayMinutes , $prefix ) : string

Specify the rate limiter configuration for the middleware.

Parameters

  • $maxAttempts int
  • $decayMinutes int
  • $prefix string
public

handle ( $request , Closure $next , $maxAttempts , $decayMinutes , $prefix ) : Symfony\...\Response

Handle an incoming request.

Parameters

  • $request Request
  • $next Closure
  • $maxAttempts int|string
  • $decayMinutes float|int
  • $prefix string
protected

handleRequestUsingNamedLimiter ( $request , Closure $next , $limiterName , Closure $limiter ) : Symfony\...\Response

Handle an incoming request.

Parameters

protected

handleRequest ( $request , Closure $next , array $limits ) : Symfony\...\Response

Handle an incoming request.

Parameters

protected

resolveMaxAttempts ( $request , $maxAttempts ) : int

Resolve the number of attempts if the user is authenticated or not.

Parameters

  • $request Request
  • $maxAttempts int|string
protected

resolveRequestSignature ( $request ) : string

Resolve request signature.

Parameters

protected

buildException ( $request , $key , $maxAttempts , $responseCallback ) : ThrottleRequestsException |HttpResponseException

Create a 'too many attempts' exception.

Parameters

  • $request Request
  • $key string
  • $maxAttempts int
  • $responseCallback callable|null
protected

getTimeUntilNextRetry ( $key ) : int

Get the number of seconds until the next retry.

Parameters

  • $key string
protected

addHeaders ( Symfony\...\Response $response , $maxAttempts , $remainingAttempts , $retryAfter ) : Symfony\...\Response

Add the limit header information to the given response.

Parameters

  • $response Symfony\...\Response
  • $maxAttempts int
  • $remainingAttempts int
  • $retryAfter int|null
protected

getHeaders ( $maxAttempts , $remainingAttempts , $retryAfter , Symfony\...\Response $response ) : array

Get the limit headers information.

Parameters

  • $maxAttempts int
  • $remainingAttempts int
  • $retryAfter int|null
  • $response Symfony\...\Response|null
protected

calculateRemainingAttempts ( $key , $maxAttempts , $retryAfter ) : int

Calculate the number of remaining attempts.

Parameters

  • $key string
  • $maxAttempts int
  • $retryAfter int|null
private

formatIdentifier ( $value ) : string

Format the given identifier based on the configured hashing settings.

Parameters

  • $value string
public static

shouldHashKeys ( bool $shouldHashKeys ) : void

Specify whether rate limiter keys should be hashed.

Parameters

  • $shouldHashKeys bool