Created
March 24, 2014 11:57
-
-
Save grimrose/9738855 to your computer and use it in GitHub Desktop.
#yurufuwa_scala
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 org.vertx.scala.core.http.HttpServerRequest | |
import org.vertx.scala.platform.Verticle | |
import java.util.Date | |
import org.vertx.scala.core.json.Json | |
class HelloWorldServer extends Verticle { | |
override def start() { | |
vertx.createHttpServer().requestHandler { | |
request: HttpServerRequest => | |
request.response().headers().addBinding("Content-Type", "application/json") | |
val status = "ok" | |
val array = Json.arr("Hello", "Vert.x", "Scala!") | |
val date = new Date | |
val json = Json.obj( | |
"status" -> status, | |
"message" -> array, | |
"date" -> date.toString | |
) | |
request.response().end(json.encodePrettily()) | |
}.listen(8080) | |
logger.info("start server!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment