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

responses: make messages and errors default if not present #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cloudflare/src/framework/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use serde_json::value::Value as JsonValue;
pub struct ApiSuccess<ResultType> {
pub result: ResultType,
pub result_info: Option<JsonValue>,
#[serde(default)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more correct to make this Option<JsonValue>, rather than defaulting to JsonValue::Null. What do you think @sssilver -- one downside is that it would be a breaking change (although a very easy to fix one)

Copy link
Collaborator Author

@Noah-Kennedy Noah-Kennedy Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @adamchalmers here. The reason I chose to do it this way is that I felt that we could do just a simple patch release with the changes from this and #174 if we kept this nonbreaking. However, I think that Adam's idea is the better API, and I was originally contemplating doing that for this reason.

pub messages: JsonValue,
#[serde(default)]
pub errors: Vec<ApiError>,
}

Expand Down