Created
February 10, 2012 22:39
-
-
Save keesun/1793640 to your computer and use it in GitHub Desktop.
Vert.x HttpServer Demo
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 http; | |
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.app.VertxApp; | |
import org.vertx.java.core.http.HttpServer; | |
import org.vertx.java.core.http.HttpServerRequest; | |
/** | |
* @author Keesun Baik | |
*/ | |
public class HttpWebServer implements VertxApp{ | |
HttpServer httpServer; | |
@Override | |
public void start() throws Exception { | |
httpServer = new HttpServer().requestHandler(new Handler<HttpServerRequest>() { | |
public void handle(HttpServerRequest req) { | |
System.out.println(req); | |
req.response.putHeader("Content-Type", "text/html; charset=UTF-8") | |
.end("<html><h1>Hello Vert.x</hi></html>"); | |
} | |
}).listen(8080); | |
} | |
@Override | |
public void stop() throws Exception { | |
httpServer.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment