\Framework\MiddlewareRateLimitMiddleware

Summary

Methods
Properties
Constants
__construct()
handle()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
buildRateLimitResponse()
matchPath()
$maxRequests
$period
$except
$redis
$config
N/A

Properties

$maxRequests

$maxRequests : int

Type

int

$period

$period : int

Type

int

$except

$except : array

Type

array

$redis

$redis : \Redis

Type

\Redis — [MODIFIED] 声明 Redis 属性

$config

$config : array

Type

array

Methods

__construct()

__construct(array  $config, object  $redis) : mixed

[MODIFIED] 构造函数现在接收 \Redis 实例,而不是 $cacheDir.

Parameters

array $config
object $redis

Returns

mixed —

handle()

handle(\Symfony\Component\HttpFoundation\Request  $request, callable  $next) : \Symfony\Component\HttpFoundation\Response

处理请求并应用限流

Parameters

\Symfony\Component\HttpFoundation\Request $request
callable $next

接收 Request 并返回 Response 的下一个处理器

Returns

\Symfony\Component\HttpFoundation\Response —

buildRateLimitResponse()

buildRateLimitResponse(\Symfony\Component\HttpFoundation\Request  $request, int  $retryAfter) : \Symfony\Component\HttpFoundation\Response

[MODIFIED] 签名保持不变,内部逻辑也无需大改.

Parameters

\Symfony\Component\HttpFoundation\Request $request
int $retryAfter

Returns

\Symfony\Component\HttpFoundation\Response —

matchPath()

matchPath(string  $path, string  $pattern) : bool

(保持不变).

Parameters

string $path
string $pattern

Returns

bool —