You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the API server usually returns some JSON object in the response for the non-successful status codes. Currently this means users that want this value have to parse it from the response buffer, which in turn means clients have to expose the response buffer along side the parsed response type.
So it would be useful to type Unauthorized, etc as (serde_json::Value). Usually it's a Status, but that would require emitting other variants that aren't Status to be safe. In any case, a serde_json::Value can be redeserialized as a Status if the user wants that.
The text was updated successfully, but these errors were encountered:
…associated type.
The spec does not record any possible HTTP status codes other than
HTTP 200, 201, 202 and 401. But in common operation, many APIs can fail with
HTTP 403, GETs on non-existent resources can fail with HTTP 404, and PUTs on
resources with the wrong resource version can fail with HTTP 409.
This commit ignores all variants that don't have an associated type in the spec.
This commit also changes the `Other` variant to have a
`Result<Option<serde_json::Value>, serde_json::Error>` value. This allows
the variant to handle the common case where the response contains a JSON value,
but still allow the case of non-JSON content that the user should parse from
the response body manually.
Fixes#40Fixes#41
For example:
However, the API server usually returns some JSON object in the response for the non-successful status codes. Currently this means users that want this value have to parse it from the response buffer, which in turn means clients have to expose the response buffer along side the parsed response type.
So it would be useful to type
Unauthorized
, etc as(serde_json::Value)
. Usually it's aStatus
, but that would require emitting other variants that aren'tStatus
to be safe. In any case, aserde_json::Value
can be redeserialized as aStatus
if the user wants that.The text was updated successfully, but these errors were encountered: