camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Kennedy <g...@apnic.net>
Subject Re: Setting rest response json directly
Date Wed, 05 Nov 2014 23:23:08 GMT
I'm using blueprint, but yes, it does not work.

    <cml:setBody>
        <cml:simple>{ "exception": "${exception.message}" }</cml:simple>
    </cml:setBody>

Produces response content of:
    "{ \"error\": \"${exception.message}\" }"

Instead of:
    { "error": "${exception.message}" }


I'm using the servlet/rest config, ie:
    <camelContext>
        <restConfiguration component="servlet" bindingMode="json"/>
        <rest consumes="application/json" produces="application/json">
            <post>
                <route>
                    < !-- lots of magic -->
                    <onException>
                        <exception>net.me.MyException</exception>
                        <handled><constant>true</constant></handled>
                        < !-- more magic -->
                        <setBody>
                            <simple>{ "error": "${exception.message}"
}</simple>
                        </setBody>
                    </onException>
                </route>
            </post>
        </rest>
    </camelContext>

(Sorry. I should have included this snippet in the first email)

Cheers,
Gary




--
View this message in context: http://camel.465427.n5.nabble.com/Setting-rest-response-json-directly-tp5758518p5758563.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message