I wanted to add the db creation timestamp in rfc3339 format for each entry so I did the following modifications.
Added date to Resource struct
#[serde(serialize_with = "serialize_date")]
created: Option<DateTime<Local>>,
Added serialization function in common.rs
pub fn serialize_date<S>(_: &Option<chrono::DateTime<Local>>, s: S) -> Result<S::Ok, S::Error>
where S: Serializer {
match Some(Local::now().to_rfc3339()) {
Some(w) => s.serialize_str(&w),
None => s.serialize_none()
}
}
When the GET method is triggered, the current date is shown for all the retrieved entries even if the database is being populated correctly. I want the dates from the database to be returned when retrieving the database contents through GET.
I wanted to add the db creation timestamp in rfc3339 format for each entry so I did the following modifications.
Added date to
ResourcestructAdded serialization function in
common.rsWhen the
GETmethod is triggered, the current date is shown for all the retrieved entries even if the database is being populated correctly. I want the dates from the database to be returned when retrieving the database contents throughGET.