Skip to content

Caryatid: Improve RESTResponse::with_json to take T: Serialize #6

@sandtreader

Description

@sandtreader

Suggestion from @SupernaviX to improve REST handlers - if RESTResponse::with_json() could take a T: Serialize, and returned a Result<()>, it could do the serialisation and error handling itself:

                            Some(stake) => match serde_json::to_string(&stake) {
                                Ok(body) => Ok(RESTResponse::with_json(200, &body)),
                                Err(error) => Err(anyhow!("{:?}", error)),
                            },

becomes

                            Some(stake) => RESTResponse::with_json(200, &stake)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions