class ThrottleApi implements ExtenderInterface

Methods

set(string $name, string|callable $callback)

<p>Add a new throttler (or override one with the same name).</p>

remove(string $name)

<p>Remove a throttler registered with this name.</p>

extend(Container $container, Extension $extension = null)

No description

Details

ThrottleApi set(string $name, string|callable $callback)

<p>Add a new throttler (or override one with the same name).</p>

Parameters

string $name
string|callable $callback <p>The callable can be a closure or invokable class, and should accept:</p> <ul> <li>$request: The current <code>\Psr\Http\Message\ServerRequestInterface</code> request object. <code>\Flarum\Http\RequestUtil::getActor($request)</code> can be used to get the current user. <code>$request-&gt;getAttribute('routeName')</code> can be used to get the current route. Please note that every throttler runs by default on every route. If you only want to throttle certain routes, you'll need to check for that inside your logic.</li> </ul> <p>The callable should return one of:</p> <ul> <li><code>false</code>: This marks the request as NOT to be throttled. It overrides all other throttlers</li> <li><code>true</code>: This marks the request as to be throttled. All other outputs will be ignored.</li> </ul>

Return Value

ThrottleApi

ThrottleApi remove(string $name)

<p>Remove a throttler registered with this name.</p>

Parameters

string $name

Return Value

ThrottleApi

extend(Container $container, Extension $extension = null)

Parameters

Container $container
Extension $extension