Last active
November 14, 2017 06:15
-
-
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
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
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) | |
} |
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
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+' | |
} |
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
gradle run |
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
compile 'io.vertx:vertx-web:3.+' | |
compile 'io.vertx:vertx-web-scala_2.12:3+' |
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
val srv = vertx.createHttpServer() | |
srv.requestHandler(router.accept _).listen(8080) |
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
gradle run & | |
curl http://localhost:8080 |
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
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