Neuron-PHP

RateLimitResponse
in package

Rate limit response formatter.

Handles HTTP 429 responses with appropriate headers.

Table of Contents

Methods

buildInfo()  : array<string|int, mixed>
Build rate limit info array.
send()  : void
Send rate limit exceeded response.
sendHtmlResponse()  : void
Send HTML error response.
sendJsonResponse()  : void
Send JSON error response.

Methods

buildInfo()

Build rate limit info array.

public static buildInfo(int $limit, int $remaining, int $resetTime) : array<string|int, mixed>
Parameters
$limit : int
$remaining : int
$resetTime : int
Return values
array<string|int, mixed>

send()

Send rate limit exceeded response.

public static send(int $limit, int $remaining, int $resetTime[, string $message = '' ]) : void
Parameters
$limit : int

Maximum requests allowed

$remaining : int

Remaining requests

$resetTime : int

Unix timestamp when limit resets

$message : string = ''

Custom error message

sendHtmlResponse()

Send HTML error response.

private static sendHtmlResponse(int $limit, int $remaining, int $resetTime, string $message) : void
Parameters
$limit : int
$remaining : int
$resetTime : int
$message : string

sendJsonResponse()

Send JSON error response.

private static sendJsonResponse(int $limit, int $remaining, int $resetTime, string $message) : void
Parameters
$limit : int
$remaining : int
$resetTime : int
$message : string

        
On this page

Search results