Skip to content

Instantly share code, notes, and snippets.

@franzwong
Created April 6, 2018 11:27
Show Gist options
  • Save franzwong/bbabcc47650ce50c6d6b69ec15ad2f3a to your computer and use it in GitHub Desktop.
Save franzwong/bbabcc47650ce50c6d6b69ec15ad2f3a to your computer and use it in GitHub Desktop.
Simple Vert.x Webapp
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