Skip to content

Instantly share code, notes, and snippets.

@InfoSec812
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save InfoSec812/801a247cd20713e592cc to your computer and use it in GitHub Desktop.

Select an option

Save InfoSec812/801a247cd20713e592cc to your computer and use it in GitHub Desktop.
A basic example of using vertx-web and it's "router" functionality to handle HTTP requests.
package com.mycompany.vertx.demo;
import io.vertx.core.AbstractVerticle;
import io.vertx.ext.web.Router;
public class WebServer extends AbstractVerticle {
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.get("/").handler(routingContext -> {
routingContext.response().end("Index Page");
});
router.route().handler(routingContext -> {
routingContext.request().response().end("Hello Vert.x");
});
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment