1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 08:55:16 +00:00

Make limit system lives

This commit is contained in:
2021-01-23 09:44:34 +01:00
parent dac83ba437
commit ddce4062c7
4 changed files with 116 additions and 16 deletions

View File

@ -146,6 +146,13 @@ impl HttpRequestHandler {
Err(Box::new(ExecError::new(&message)))
}
/// Too many requests (429)
pub fn too_many_requests(&mut self, message: &str) -> RequestResult {
self.response = Some(HttpResponse::TooManyRequests().json(
HttpError::new(429, message)));
Err(Box::new(ExecError::new(message)))
}
/// If result is not OK, return a bad request
pub fn ok_or_bad_request<E>(&mut self, res: ResultBoxError<E>, msg: &str) -> ResultBoxError<E> {
match res {