title is now also part of the whole process
This commit is contained in:
@@ -12,12 +12,14 @@ use crate::types::Alarm;
|
||||
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
pub struct RequestBody {
|
||||
title: String,
|
||||
time: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(ToSchema, Serialize)]
|
||||
pub struct OkResponseBody {
|
||||
time: DateTime<Utc>,
|
||||
title: String,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ impl IntoResponse for Responses {
|
||||
|
||||
impl From<Alarm> for OkResponseBody {
|
||||
fn from(value: Alarm) -> Self {
|
||||
OkResponseBody { time: value.time, enabled: value.enabled }
|
||||
OkResponseBody { time: value.time, enabled: value.enabled, title: value.title }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +56,7 @@ impl From<Alarm> for OkResponseBody {
|
||||
)]
|
||||
#[debug_handler]
|
||||
pub async fn post_handler(State(AppState { scheduler, ..}): State<AppState>, Json(body): Json<RequestBody>) -> Responses {
|
||||
let result = scheduler.add_alarm(body.time).await;
|
||||
let result = scheduler.add_alarm(body.time, body.title).await;
|
||||
|
||||
match result {
|
||||
Ok(alarm) => {
|
||||
|
||||
Reference in New Issue
Block a user