Skip to content

Commit

Permalink
fixes #1865 Rate limit above threshold hits cannot be easily reported (
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu authored Aug 15, 2023
1 parent e1d958f commit a4cc118
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().add(new HttpString(Constants.RATELIMIT_RESET), rateLimitResponse.getHeaders().get(Constants.RATELIMIT_RESET));

exchange.getResponseHeaders().add(new HttpString("Content-Type"), "application/json");
exchange.setStatusCode(config.getErrorCode()==0 ? HttpStatus.TOO_MANY_REQUESTS.value():config.getErrorCode());
if(logger.isDebugEnabled()) logger.debug("LimitHandler.handleRequest ends with an error.");
int statusCode = config.getErrorCode()==0 ? HttpStatus.TOO_MANY_REQUESTS.value():config.getErrorCode();
exchange.setStatusCode(statusCode);
if(logger.isDebugEnabled()) logger.warn("LimitHandler.handleRequest ends with an error code {}", statusCode);
exchange.getResponseSender().send(mapper.writeValueAsString(rateLimitResponse));
}
}
Expand Down

0 comments on commit a4cc118

Please sign in to comment.