From 8df5fff105327431a837b6d3cc35eb2a24974898 Mon Sep 17 00:00:00 2001 From: Lars Jellema Date: Thu, 21 Apr 2022 23:02:14 +0200 Subject: [PATCH] Use boolean ok field for api --- backend/src/api.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/src/api.rs b/backend/src/api.rs index dda99bc..bf8ccf3 100644 --- a/backend/src/api.rs +++ b/backend/src/api.rs @@ -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>, #[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)), }