Skip to content

Instantly share code, notes, and snippets.

@vietj

vietj/test.java

Created Jul 14, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.