diff options
Diffstat (limited to 'atuin-common/src/api.rs')
-rw-r--r-- | atuin-common/src/api.rs | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/atuin-common/src/api.rs b/atuin-common/src/api.rs index 803fbbcc..47bbcde1 100644 --- a/atuin-common/src/api.rs +++ b/atuin-common/src/api.rs @@ -1,8 +1,5 @@ -use std::borrow::Cow; - -use axum::{response::IntoResponse, Json}; use chrono::Utc; -use serde::Serialize; +use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct UserResponse { @@ -56,34 +53,3 @@ pub struct SyncHistoryRequest { pub struct SyncHistoryResponse { pub history: Vec<String>, } - -#[derive(Debug, Serialize, Deserialize)] -pub struct ErrorResponse<'a> { - pub reason: Cow<'a, str>, -} - -impl<'a> IntoResponse for ErrorResponseStatus<'a> { - fn into_response(self) -> axum::response::Response { - (self.status, Json(self.error)).into_response() - } -} - -pub struct ErrorResponseStatus<'a> { - pub error: ErrorResponse<'a>, - pub status: http::StatusCode, -} - -impl<'a> ErrorResponse<'a> { - pub fn with_status(self, status: http::StatusCode) -> ErrorResponseStatus<'a> { - ErrorResponseStatus { - error: self, - status, - } - } - - pub fn reply(reason: &'a str) -> ErrorResponse { - Self { - reason: reason.into(), - } - } -} |