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

Start to return user information

This commit is contained in:
2020-05-25 13:25:51 +02:00
parent 97d9adcc03
commit be4d1befcc
7 changed files with 80 additions and 7 deletions

View File

@ -118,6 +118,13 @@ impl HttpRequestHandler {
Err(Box::new(ExecError::new(&message)))
}
/// Not found (404)
pub fn not_found(&mut self, message: String) -> RequestResult {
self.response = Some(HttpResponse::NotFound().json(
HttpError::not_found(&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 {
@ -236,6 +243,11 @@ impl HttpRequestHandler {
}
}
/// Get an integer included in the POST request
pub fn post_i64(&mut self, name: &str) -> ResultBoxError<i64> {
Ok(self.post_string(name)?.parse::<i64>()?)
}
/// Get user ID. This function assess that a user ID is available to continue
pub fn user_id(&self) -> ResultBoxError<UserID> {
match self.curr_user_id {