drogon
C++14/17-based HTTP application framework
Loading...
Searching...
No Matches
drogon::RateLimiter Class Referenceabstract

This class is used to limit the number of requests per second. More...

#include <drogon/RateLimiter.h>

Inheritance diagram for drogon::RateLimiter:

Public Member Functions

virtual bool isAllowed ()=0
 Check if a request is allowed.

Static Public Member Functions

static RateLimiterPtr newRateLimiter (RateLimiterType type, size_t capacity, std::chrono::duration< double > timeUnit=std::chrono::seconds(60))
 Create a rate limiter.

Detailed Description

This class is used to limit the number of requests per second.

Member Function Documentation

◆ isAllowed()

virtual bool drogon::RateLimiter::isAllowed ( )
pure virtual

Check if a request is allowed.

Returns
true The request is allowed
false The request is not allowed

Implemented in drogon::SafeRateLimiter.

◆ newRateLimiter()

RateLimiterPtr drogon::RateLimiter::newRateLimiter ( RateLimiterType type,
size_t capacity,
std::chrono::duration< double > timeUnit = std::chrono::seconds(60) )
static

Create a rate limiter.

Parameters
typeThe type of the rate limiter
capacityThe maximum number of requests in the time unit.
timeUnitThe time unit of the rate limiter.
Returns
A rate limiter pointer

The documentation for this class was generated from the following file: