this.httpServer.requestHandler(new CorsHandler(getHttpHandler()));
this.sockServer.installApp(new JsonObject().putString("prefix", "/socket"), new SockJSHandler());
}
private Handler<HttpServerRequest> getHttpHandler() {
RouteMatcher matcher = new RouteMatcher();
matcher.get("/", new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest request) {
request.response.end("This is the SpringOne Push Messaging Service");
}
});
matcher.post("/messages/:topic/", new Handler<HttpServerRequest>() {
public void handle(final HttpServerRequest request) {
final String topic = request.params().get("topic");
request.bodyHandler(new Handler<Buffer>(){
public void handle(Buffer body) {
JsonObject message =
new JsonObject().putString("topic", topic).
putObject("message", new JsonObject(body.toString()));
System.out.println("Publishing message: "+message.toString());
vertx.eventBus().publish(RabbitService.PUBLISH, message);
request.response.end("ok");
}
});
}
});
matcher.post("/subscriptions/:bindingKey/", new Handler<HttpServerRequest>(){
public void handle(final HttpServerRequest request) {
final String bindingKey = request.params().get("bindingKey");
request.bodyHandler(new Handler<Buffer>(){
public void handle(Buffer body) {