-
Notifications
You must be signed in to change notification settings - Fork 630
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
Users want to customize status response when schema validation fails #841
Comments
@jiachen1120 This is a good approach to customize the error message. To extend the concept of error message customization, one organization is asking if we can hide the detail of the status response to only the response code and error code for north-south traffic and keep the entire status response for east-west traffic. There is a security concern to send the full status object to the client coming from the Internet. If the Internet user receives the error, they don't know what is going on and they have to report to the API owner who can search the runbook to find the full text of descriptions as well as the resolutions in different scenarios. |
@stevehu Thanks Steve. We also believe that it is good to provide users with customized error message. Therefore, can we make a pull request for this? |
Yes. Please. |
@jiachen1120 One suggestion... The "I" in IStatusFactory does not align with the naming conventions in light-4j... I would suggest renaming this interface to simply StatusFactory... @stevehu what do you think? |
@jiachen1120 I think @miklish is right. It is seldom for us to use I as a prefix these days as the modern IDE has a clear indicator on which file is a class and which one is an interface. The prefix will make the interface name not a valid word and causing some warnings in some IDEs. The practice was pretty popular in the old days that IDE doesn't have any indication on the class type. Thanks. |
- added StatusWrapper interface
When schame validation fails, the framework will directly return the error status object {"statusCode":400 ...}. However, one of our user want to add their own information into this status response.
A generic way to implement it is to provide users a status wrapper interface and let user costomize their own Status and them inject the customized status into framework through SingletonFactory
example:
User implement the IStatusFactory and configure service.yml
Within LightHttpHandler.setExchangeStatus() method:
Looking forward to your opinion. Thanks
The text was updated successfully, but these errors were encountered: