spring-cloud / spring-cloud/spring-cloud-openfeign
Add ability to not throw exception when http status code > 399
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.3k
- Forks
- 838
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 13
Description
urrently our team convention is to use response status instead of throwing exception. Say our model is like this:
public class BaseResponse {
private String message;
private int httpStatusCode;
private Boolean isFailed;
private int errorCode;
}
So when our API endpoint failed, we return BaseResponse with failed status instead. Now this is not possible to be read by the client using openfeign since feign will throw exception directly if >399 response status retrieved, so our returned response is useless. We can make our api to return 200 status code instead, but that would violate RESTFUL.
Understand that openfeign is designed to be strictly RESTFUL, but I don't think forcing your user to throw exception is the right thing, because different teams have different convention used on how they handle the failure, and in our case we use our response entity that would describe the failure status.
I appreciate if this feature can be considered, and I will be happy to contribute if needed. Thank you.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the OpenFeign client handles responses with HTTP status codes above 399. Define an opt-in behavior that lets callers receive the returned response entity instead of an exception, and verify that the existing exception behavior remains unchanged when the option is not enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100