camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Customize the Http Response Code for REST Service
Date Fri, 25 Mar 2016 08:03:54 GMT
Hi

Yeah there is also an example in the CiA 2nd ed book

xml

https://github.com/camelinaction/camelinaction2/blob/master/chapter10/servlet-swagger-xml/src/main/resources/camel.xml

and for java

https://github.com/camelinaction/camelinaction2/blob/master/chapter10/undertow-swagger/src/main/java/camelinaction/OrderRoute.java

On Fri, Mar 25, 2016 at 9:00 AM, fabrizio.spataro
<fabrizio.spataro@bizmate.it> wrote:
> Hello,
>
> I had same problem and i resolve it using "onException tag" to intercept
> validation error and return another http response code
>
> Example DSL:
>
> <camelContext ...>
>   <onException>
>     <exception>java.your.exception</exception>
>         <setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
>                 <constant>403</constant>
>         </setHeader>
>          <handled><constant>true</constant></handled>
>    </onException>
> .....
> ....
> </camelContext>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Customize-the-Http-Response-Code-for-REST-Service-tp5779682p5779691.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Mime
View raw message