Advertisement
Guest User

Camel REST DSL Redirect with Restlet

a guest
Apr 1st, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.61 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4.       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.       xmlns:camel="http://camel.apache.org/schema/spring"
  6.       xsi:schemaLocation="
  7.       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  8.       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  9.  
  10. <camelContext xmlns="http://camel.apache.org/schema/spring">
  11.  
  12. <restConfiguration component="restlet" port="8080"/>
  13.  
  14. <rest path="/">
  15.         <get uri="/test" >
  16.             <to uri="direct:Test"/>
  17.         </get>
  18. </rest>
  19.  
  20. <route>
  21.   <from uri="direct:Test"/>
  22.   <transform><groovy><![CDATA[
  23.       exchange.out.headers.'Content-Type' = 'text/html;charset=UTF-8'
  24.       exchange.out.headers[org.apache.camel.Exchange.HTTP_RESPONSE_CODE] = 302
  25.      
  26.       def locationUri='http://yahoo.com'
  27.      
  28.       // This doesn't work
  29.       // The console outputs:
  30.       // Apr 01, 2015 1:56:01 PM org.restlet.engine.header.HeaderUtils addExtensionHeaders
  31.       // WARNING: Addition of the standard header "location" is not allowed. Please use the equivalent property in the Restlet API.
  32.       //
  33.       // exchange.out.headers.location = locationUri
  34.      
  35.       // This works
  36.       def response = exchange.getIn().getHeader('CamelRestletResponse')
  37.       response.setLocationRef(locationUri)
  38.      
  39.       $/<html><body><a href="${locationUri}">redirect</a></body></html>/$
  40.  ]]></groovy>
  41.   </transform>
  42. </route>
  43.  
  44. </camelContext>
  45. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement