Skip to content

Instantly share code, notes, and snippets.

@crised
Created May 20, 2014 15:57
Show Gist options
  • Save crised/5eba68169fab5f2d3c85 to your computer and use it in GitHub Desktop.
Save crised/5eba68169fab5f2d3c85 to your computer and use it in GitHub Desktop.
public class Server extends Verticle {
Vertx vertx = VertxFactory.newVertx();
public void start() {
vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest req) {
System.out.println("Got request: " + req.uri());
System.out.println("Headers are: ");
for (Map.Entry<String, String> entry : req.headers()) {
System.out.println(entry.getKey() + ":" + entry.getValue());
}
req.response().headers().set("Content-Type", "text/json; charset=UTF-8");
if (Json.jsonString == null) {
req.response().end("");
} else {
req.response().end(Json.jsonString);
}
}
}).listen(8080);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment