Created
April 6, 2018 11:27
-
-
Save franzwong/bbabcc47650ce50c6d6b69ec15ad2f3a to your computer and use it in GitHub Desktop.
Simple Vert.x Webapp
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
import io.vertx.core.Vertx | |
import io.vertx.core.json.Json | |
import io.vertx.ext.web.Router | |
data class Person( | |
val name: String, | |
val nationality: String | |
) { | |
} | |
fun main(args : Array<String>) { | |
val vertx = Vertx.vertx() | |
var server = vertx.createHttpServer() | |
val router = Router.router(vertx) | |
router.get("/users").handler({routingContext -> | |
routingContext.response() | |
.putHeader("content-type", "application/json; charset=utf-8") | |
.end(Json.encode(Person("Franz", "HK"))); | |
}) | |
server.requestHandler({ router.accept(it) }).listen(8080) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment