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)));
}
};
}
Aggregations