I am developing REST services using camel REST-DSL [in camel documentation] component.I am successful in sending JSON request for happy path and get the response on the same using (Rest-DSL and camel servlet) combination. Now as we move forward the client may sent Rest Service request with not enough values or invalid valid request ,now I am looking for ways to send 400 status code as a response from REST DSL when request is not valid.
Please advise on the way to achieve this.
I am assuming you are doing your validation in a custom processor or something similiar. If you want to send your an HTTP Error code just add the header Exchange.HTTP_RESPONSE_CODE.
For example : exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 400);
The behaviour may depend of the engine you use. As documentation says it should work with servlet engine :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With