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: Setting rest response json directly
Date Wed, 05 Nov 2014 06:22:54 GMT
Hi

And using

    .setBody(simple("{ \"error\": \"${exception.message}\" }"))

Does not work?






On Wed, Nov 5, 2014 at 7:02 AM, Gary Kennedy <gary@apnic.net> wrote:
> Greetings all,
>
> I'm using the camel rest dsl in a karaf osgi blueprint to define my route (and I love
it, so easy), and I've got an onException block properly handling my (known) exceptions for
an 'application/json' POST endpoint.
>
> I've set it to produce 'application/json' and when things go well it works fine.
>
> However, on the exception case I want to respond with a json body containing the exception
message.
> e.g., { "error": "${exception.message}" }
>
> When I use setBody to do the above, the response is a json string of the above instead
of the above as json. (Does that make sense??)
>
> So how can I set a json response body from a simple (dsl) string?
>
> Cheers,
> Gary
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message