/
PlayFramework.sc
35 lines (34 loc) · 960 Bytes
/
PlayFramework.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Single-file play framework application!
*/
import $ivy.{
`com.typesafe.play::play:2.5.0`,
`com.typesafe.play::play-netty-server:2.5.0`,
`org.scalaj::scalaj-http:2.2.1`
}
import play.core.server._, play.api.routing.sird._, play.api.mvc._
import scalaj.http._
val server = NettyServer.fromRouter(new ServerConfig(
rootDir = new java.io.File("."),
port = Some(19000), sslPort = None,
address = "0.0.0.0", mode = play.api.Mode.Dev,
properties = System.getProperties,
configuration = play.api.Configuration(
"play.server.netty" -> Map(
"maxInitialLineLength" -> 4096,
"maxHeaderSize" -> 8192,
"maxChunkSize" -> 8192,
"log.wire" -> false,
"eventLoopThreads" -> 0,
"transport" -> "jdk",
"option.child" -> Map()
)
)
)) {
case GET(p"/hello/$to") => Action { Results.Ok(s"Hello $to") }
}
try {
println(Http("http://localhost:19000/hello/bar").asString.body)
} finally{
server.stop()
}