Skip to content

Instantly share code, notes, and snippets.

@aya-eiya
Last active November 14, 2017 06:15
Show Gist options
  • Save aya-eiya/b17fb83f70d41b04af3b8284dbf802d4 to your computer and use it in GitHub Desktop.
Save aya-eiya/b17fb83f70d41b04af3b8284dbf802d4 to your computer and use it in GitHub Desktop.
vert.x+Scala build with GradleでWebサービス作ってみる ref: https://qiita.com/aya_eiya/items/e9eb2306e93772d4ba95
package jp.sample
import io.vertx.scala.core.Vertx
import io.vertx.scala.ext.web._
object App {
def main(args : Array[String]) {
val vertx = Vertx.vertx()
val router = Router.router(vertx)
router.route().handler(context=>{
val res = context.response()
res.putHeader("content-type","text/plane")
res.end("Hello world.")
})
val srv = vertx.createHttpServer()
srv.requestHandler(router.accept _).listen(8080)
}
plugins {
id 'application'
id 'java'
id 'scala'
}
repositories {
mavenCentral()
jcenter()
}
version = '0.1.0-SNAPSHOT'
sourceCompatibility = '1.8'
mainClassName = 'jp.sample.App'
dependencies {
compile 'io.vertx:vertx-core:3.+'
compile 'io.vertx:vertx-lang-scala_2.12:3.+'
compile 'io.vertx:vertx-web:3.+'
compile 'io.vertx:vertx-web-scala_2.12:3+'
}
compile 'io.vertx:vertx-web:3.+'
compile 'io.vertx:vertx-web-scala_2.12:3+'
val srv = vertx.createHttpServer()
srv.requestHandler(router.accept _).listen(8080)
gradle run &
curl http://localhost:8080
val router = Router.router(vertx)
router.route().handler(context=>{
val res = context.response()
res.putHeader("content-type","text/plane")
res.end("Hello world.")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment