Package com.exedio.cops
Class RequestLimiter
- java.lang.Object
-
- com.exedio.cops.RequestLimiter
-
public final class RequestLimiter extends Object
-
-
Constructor Summary
Constructors Constructor Description RequestLimiter(int threshold, int interval, String denyMessage)
RequestLimiter(int threshold, int interval, String denyMessage, String denyBody)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
doRequest(HttpServletRequest request, HttpServletResponse response)
void
init(ServletConfig config)
-
-
-
Constructor Detail
-
RequestLimiter
public RequestLimiter(int threshold, int interval, String denyMessage)
- Parameters:
threshold
- the number of request allowed in one interval, until further requests in that interval are deniedinterval
- the length of the interval in milliseconds
-
-
Method Detail
-
init
public void init(ServletConfig config)
-
doRequest
public boolean doRequest(HttpServletRequest request, HttpServletResponse response) throws IOException
- Returns:
- whether this call has handled the request.
Do the following at the beginning of processing the request:
if(requestLimiter.doRequest(request, response)) return;
- Throws:
IOException
-
-