forked from Roflin/gamenight
Use boolean ok field for api
This commit is contained in:
parent
ced7d83fd9
commit
8df5fff105
@ -22,7 +22,7 @@ use validator::{ValidateArgs, ValidationErrors};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct ApiResponse {
|
||||
result: Cow<'static, str>,
|
||||
ok: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
message: Option<Cow<'static, str>>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -30,18 +30,15 @@ struct ApiResponse {
|
||||
}
|
||||
|
||||
impl ApiResponse {
|
||||
const SUCCES_RESULT: Cow<'static, str> = Cow::Borrowed("Ok");
|
||||
const FAILURE_RESULT: Cow<'static, str> = Cow::Borrowed("Failure");
|
||||
|
||||
const SUCCES: Self = Self {
|
||||
result: Self::SUCCES_RESULT,
|
||||
ok: true,
|
||||
message: None,
|
||||
jwt: None,
|
||||
};
|
||||
|
||||
fn login_response(jwt: String) -> Self {
|
||||
Self {
|
||||
result: Self::SUCCES_RESULT,
|
||||
ok: true,
|
||||
message: None,
|
||||
jwt: Some(Cow::Owned(jwt)),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user