aboutsummaryrefslogtreecommitdiff
path: root/src/response.rs
diff options
context:
space:
mode:
authorTolmachev Igor <me@igorek.dev>2025-09-14 23:27:25 +0300
committerTolmachev Igor <me@igorek.dev>2025-09-14 23:27:25 +0300
commit955598dce9aeb5626654c72b0ef94850123fa8ac (patch)
tree4fb161c2e67fdc161ebbca5ced271b6e7724dc30 /src/response.rs
parent39bf8397949ea2738ac3dfc934fcc3f07a6b0b66 (diff)
downloadqueue_server-955598dce9aeb5626654c72b0ef94850123fa8ac.tar.gz
queue_server-955598dce9aeb5626654c72b0ef94850123fa8ac.zip
Add openapi specs and docs
Diffstat (limited to 'src/response.rs')
-rw-r--r--src/response.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/response.rs b/src/response.rs
deleted file mode 100644
index a633570..0000000
--- a/src/response.rs
+++ /dev/null
@@ -1,54 +0,0 @@
1use axum::{
2 http::StatusCode,
3 response::{IntoResponse, Response},
4};
5use serde::Serialize;
6use serde_json::json;
7
8pub struct SuccessResponse<T>(pub T);
9pub struct FailResponse(pub String, pub String);
10pub struct ErrorResponse(pub String, pub String);
11
12impl<T> IntoResponse for SuccessResponse<T>
13where
14 T: Serialize,
15{
16 fn into_response(self) -> Response {
17 (
18 StatusCode::OK,
19 axum::Json(json!({
20 "status": "success",
21 "data": self.0
22 })),
23 )
24 .into_response()
25 }
26}
27
28impl IntoResponse for FailResponse {
29 fn into_response(self) -> Response {
30 (
31 StatusCode::BAD_REQUEST,
32 axum::Json(json!({
33 "status": "fail",
34 "kind": self.0,
35 "message": self.1
36 })),
37 )
38 .into_response()
39 }
40}
41
42impl IntoResponse for ErrorResponse {
43 fn into_response(self) -> Response {
44 (
45 StatusCode::INTERNAL_SERVER_ERROR,
46 axum::Json(json!({
47 "status": "error",
48 "kind": self.0,
49 "message": self.1
50 })),
51 )
52 .into_response()
53 }
54}