get endpoint in progress
This commit is contained in:
32
src/resources/alarm/get.rs
Normal file
32
src/resources/alarm/get.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use axum::{Json, http::StatusCode, response::IntoResponse};
|
||||
use chrono::{DateTime, Local};
|
||||
use utoipa::{IntoResponses, ToSchema};
|
||||
|
||||
#[derive(ToSchema)]
|
||||
struct OkResponse {
|
||||
name: String,
|
||||
enabled: bool,
|
||||
time: DateTime<Local>
|
||||
}
|
||||
|
||||
#[derive(IntoResponses)]
|
||||
enum Responses {
|
||||
#[response(status = 200)]
|
||||
Ok(#[to_schema] Vec<OkResponse>),
|
||||
#[response(status = 500)]
|
||||
DBError(String)
|
||||
}
|
||||
|
||||
impl IntoResponse for Responses {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
match self {
|
||||
Responses::Ok(body) => (StatusCode::OK, Json(body)).into_response(),
|
||||
Responses::DBError(message) => (StatusCode::INTERNAL_SERVER_ERROR, Json(message)).into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn get_handler() -> Responses {
|
||||
todo!()
|
||||
}
|
||||
Reference in New Issue
Block a user