tide icon indicating copy to clipboard operation
tide copied to clipboard

IntoResponse implementation for Result<A: IntoResponse, B: IntoResponse>

Open LukeMathWalker opened this issue 6 years ago • 4 comments

This closes #371 - it turns out there was already an implementation, it was just commented out :grin:

LukeMathWalker avatar Dec 22 '19 15:12 LukeMathWalker

what if I want to return a redirect?

dignifiedquire avatar Jan 01 '20 17:01 dignifiedquire

Redirects are one thing but I think it can also be perfectly fine to return HTTP 200's for errors. For example, often in GraphQL HTTP implementations one wants to return HTTP 200 for error responses as there is a distinction between success and failure responses in the serialization format.

dvic avatar Jan 03 '20 13:01 dvic

If there is consensus on the possibility of returning successes from the Err variant, I am happy to change the PR and simply cast both variants to Response without further checks.

LukeMathWalker avatar Jan 03 '20 15:01 LukeMathWalker

Updated the PR to avoid panic on the Err variant if it returns a success.

LukeMathWalker avatar Jan 03 '20 18:01 LukeMathWalker