To my knowledge, there is currently no handy feature to enable CORS on SwitchYard rest endpoints unfortunately. Please see SWITCHYARD-2460.
That said, if you can live with using the native web gateway approach for REST endpoints instead of RESTEasy bindings, then you can leverage the cool Jetty CORS filter implementation in web.xml or whatever CORS filter impls you prefer.
Hope that helps.
I used RestEasyContext mapper class to set the response headers , so from server we set were able to set the below
target.addHeader("Access-Control-Allow-Origin", "*") . It worked.
It's great that it worked for you. However, unfortunately I doubt that your context mapper approach still works under more complex CORS preflight scenarios ; the SwitchYard RESTEasy endpoint should reject HTTP "Options" requests even before they reach the context mapper. That's the exact reason I filed SWITCHYARD-2460.
It's okay so long as CORS preflight requests aren't required, but as soon as they are needed it should break. Give it a try.
Thanks Tadayoshi , yes your right about preflight requests.
I have another question regarding Switchyard . I wanted to ask you is the switchyard service extensible ?
Is there some behavior like Java's Inheritance feature in switchyard ?. From one I got to know is we have <extensions> tag through which we can extend data formats and gateway bindings ?
E.g if we have exposed a service as SOAP or Rest binding can we extend it ?
I have no ideas about the extensibility of SwitchYard services, but I doubt SwitchYard has such a feature. Perhaps it's better to ask it in a new forum thread, and other experts might help you on that question.