I develop REST services using the REST-DSL camel [in the camel documentation] . I successfully sent a JSON request for a happy journey and get an answer to the same combination (Rest-DSL and camel servlet). Now that we are moving forward, the client can send a Restore service request with invalid values or an invalid valid request, now I am looking for ways to send the 400 status code as a response from the REST DSL when the request is invalid.
Please provide information on how to do this.
, - . HTTP, Exchange.HTTP_RESPONSE_CODE.
: exchange.getIn(). setHeader (Exchange.HTTP_RESPONSE_CODE, 400);
. , :
Pierre-Alban, .
- . - -
OnException (ValidationException.class).handled() .setHeader(Exchange.HTTP_RESPONSE_CODE, (400)) .setHeader(Exchange.CONTENT_TYPE, ( "text/plain" )). setBody (exceptionMessage());