Last active
July 16, 2016 13:41
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
import io.vertx.core.AbstractVerticle; | |
import io.vertx.core.http.HttpServer; | |
import io.vertx.core.Handler; | |
import io.vertx.core.http.HttpServerRequest; | |
import io.vertx.core.http.HttpServerResponse; | |
import io.vertx.core.Verticle; | |
public class Server extends AbstractVerticle | |
{ | |
private HttpServer server = null; | |
@Override | |
public void start() throws Exception | |
{ | |
server = vertx.createHttpServer(); | |
server.requestHandler(new Handler<HttpServerRequest>() | |
{ | |
@Override | |
public void handle(HttpServerRequest request) | |
{ | |
System.out.println("Request received"); | |
HttpServerResponse response = request.response(); | |
response.setStatusCode(200); | |
response.headers() | |
.add("Content-Length", String.valueOf(57)) | |
.add("Content-Type", "text/html") | |
; | |
response.write("Hi " + (String)request.getParam("name")); | |
response.end(); | |
} | |
}); | |
server.listen(8500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment