Skip to content

While initiating GET request to actix server, it shows the same date for all the entries even though the date is different for all the entries #1

@arnabanimesh

Description

@arnabanimesh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions