cat_gateway/service/common/responses/
code_401_unauthorized.rs1use poem_openapi::{types::Example, Object};
4use uuid::Uuid;
5
6use crate::service::common;
7
8#[derive(Object)]
9#[oai(example)]
10pub(crate) struct Unauthorized {
14 id: common::types::generic::error_uuid::ErrorUuid,
16 msg: common::types::generic::error_msg::ErrorMessage,
19}
20
21impl Unauthorized {
22 pub(crate) fn new(msg: Option<String>) -> Self {
24 let msg = msg.unwrap_or(
25 "Your request was not successful because it lacks valid authentication credentials for the requested resource.".to_string(),
26 );
27 let id = Uuid::new_v4();
28
29 Self {
30 id: id.into(),
31 msg: msg.into(),
32 }
33 }
34}
35
36impl Example for Unauthorized {
37 fn example() -> Self {
39 Self::new(None)
40 }
41}