Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arnabanimesh opened this issue Nov 1, 2020 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@arnabanimesh
Copy link
Owner

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.

@arnabanimesh arnabanimesh added the help wanted Extra attention is needed label Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant