Last active
August 29, 2015 14:26
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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