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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user