Created
July 14, 2016 10:08
-
-
Save vietj/9a27b6515f771ff88c096dc10dfdd1b0 to your computer and use it in GitHub Desktop.
This file contains 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
public class Main { | |
@Path("/") | |
public static class Controller | |
{ | |
@GET | |
@Path("/{path:.*}") | |
@Produces("text/plain") | |
public String context( | |
@PathParam("path") String id, | |
@Context io.vertx.core.Context context, | |
@Context io.vertx.core.Vertx vertx, | |
@Context io.vertx.core.http.HttpServerRequest req, | |
@Context io.vertx.core.http.HttpServerResponse resp) { | |
if (context != null && vertx != null && req != null && resp != null) { | |
return Thread.currentThread().getName(); | |
} else { | |
return "fail"; | |
} | |
} | |
} | |
public static void main(String[] args) { | |
Vertx vertx = Vertx.vertx(); | |
HttpServer server = vertx.createHttpServer(); | |
VertxResteasyDeployment deployment = new VertxResteasyDeployment(); | |
deployment.start(); | |
deployment.getRegistry().addPerInstanceResource(Controller.class); | |
server.requestHandler(new VertxRequestHandler(vertx, deployment)); | |
server.listen(8080, "localhost", ar -> { | |
if (ar.succeeded()) { | |
System.out.println("started"); | |
} else { | |
ar.cause().printStackTrace(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment