Rest with Vert.x for java

flyzb發表於2013-06-22
Rest with Scala and Vert.x


支援restful java with vert.x的程式碼如下:

public class SampleResticle extends Verticle {
 
    public void start() {
        HttpServer server = vertx.createHttpServer();
        RouteMatcher routeMatcher = new RouteMatcher();
        routeMatcher.get("/hello", new Handler<HttpServerRequest>() {
            public void handle(HttpServerRequest req) {
                req.response.statusCode =200;
                req.response.end("world");
            }
        });
        server.requestHandler(routeMatcher).listen(8080, "localhost");
    }
}
<p class="indent">

相關文章