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: Adding HTTP Headers to All Jetty Routes
Date Thu, 24 Jul 2014 09:44:39 GMT
Hi

You can use a custom http binding. See about this at
http://camel.apache.org/jetty

eg just extend the default, and add those headers in the writeResponse
method, and call its super to do the actual writing.

On Tue, Jul 22, 2014 at 9:20 PM, Gavagai <tim.hoelscher@gmail.com> wrote:
> Hi all -
>
> I am trying to add some headers to the exchange's "out" on all routes.
> Specifically, I would like to add the following to support CORS:
>
>     exch.out.headers['Access-Control-Allow-Origin'] = '*'
>     exch.out.headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE,
> GET, OPTIONS'
>     exch.out.headers['Access-Control-Request-Method'] = '*'
>     exch.out.headers['Access-Control-Allow-Headers'] = 'Origin,
> X-Requested-With, Content-Type, Accept, Authorization, Cookie'
>
> I do not understand how to do this for all routes. It works great when it is
> done in a processor, but I obviously don't want to have to add these to each
> processor. I tried intercepting the message using interceptFrom(), but the
> headers so defined are not retained when the message is forwarded on to the
> next destination. I also tried setting properties on the exchange, but this
> presents problems when forming the response.
>
> What is the best way to add HTTP headers to the messages returned from all
> routes? Basically say "for every message, always add these headers as the
> final step."
>
> Tim
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Adding-HTTP-Headers-to-All-Jetty-Routes-tp5754265.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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