Search in sources :

Example 1 with EncodeRepresentation

use of org.restlet.engine.application.EncodeRepresentation in project camel by apache.

the class RestletSetBodyTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("restlet:http://localhost:" + portNum + "/stock/{symbol}?restletMethods=get").to("http://localhost:" + portNum2 + "/test?bridgeEndpoint=true").setBody().constant("110");
            from("jetty:http://localhost:" + portNum2 + "/test").setBody().constant("response is back");
            // create ByteArrayRepresentation for response
            from("restlet:http://localhost:" + portNum + "/images/{symbol}?restletMethods=get").setBody().constant(new InputRepresentation(new ByteArrayInputStream(getAllBytes()), MediaType.IMAGE_PNG, 256));
            from("restlet:http://localhost:" + portNum + "/music/{symbol}?restletMethods=get").setHeader(Exchange.CONTENT_TYPE).constant("audio/mpeg").setBody().constant(getAllBytes());
            from("restlet:http://localhost:" + portNum + "/video/{symbol}?restletMethods=get").setHeader(Exchange.CONTENT_TYPE).constant("video/mp4").setBody().constant(new ByteArrayInputStream(getAllBytes()));
            from("restlet:http://localhost:" + portNum + "/gzip/data?restletMethods=get").setBody().constant(new EncodeRepresentation(Encoding.GZIP, new StringRepresentation("Hello World!", MediaType.TEXT_XML)));
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) InputRepresentation(org.restlet.representation.InputRepresentation) ByteArrayInputStream(java.io.ByteArrayInputStream) StringRepresentation(org.restlet.representation.StringRepresentation) EncodeRepresentation(org.restlet.engine.application.EncodeRepresentation)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 EncodeRepresentation (org.restlet.engine.application.EncodeRepresentation)1 InputRepresentation (org.restlet.representation.InputRepresentation)1 StringRepresentation (org.restlet.representation.StringRepresentation)1