Created
April 1, 2016 12:38
-
-
Save lihaoyi/3d4b2e979267a25db3845f152db82865 to your computer and use it in GitHub Desktop.
Running a PlayFramework server, right in the REPL!
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
haoyi-mbp:test haoyi$ ~/amm | |
Loading... | |
Welcome to the Ammonite Repl 0.5.7 | |
(Scala 2.11.8 Java 1.8.0_25) | |
haoyi-test@ load.ivy("com.typesafe.play" %% "play" % "2.5.0") | |
haoyi-test@ load.ivy("com.typesafe.play" %% "play-netty-server" % "2.5.0") | |
haoyi-test@ import play.core.server._, play.api.routing.sird._, play.api.mvc._ | |
import play.core.server._, play.api.routing.sird._, play.api.mvc._ | |
haoyi-test@ val server = NettyServer.fromRouter(new ServerConfig( | |
rootDir = new java.io.File("."), | |
port = Some(19000), sslPort = None, | |
address = "127.0.0.1", 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") } | |
} | |
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". | |
SLF4J: Defaulting to no-operation (NOP) logger implementation | |
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. | |
server: NettyServer = play.core.server.NettyServer@7ad4085c | |
haoyi-test@ load.ivy("org.scalaj" %% "scalaj-http" % "2.2.1") | |
haoyi-test@ import scalaj.http._ | |
import scalaj.http._ | |
haoyi-test@ Http("http://localhost:19000/hello/bar").asString | |
res6: HttpResponse[String] = HttpResponse( | |
"Hello bar", | |
200, | |
Map( | |
"Content-Length" -> Vector("9"), | |
"Content-Type" -> Vector("text/plain; charset=utf-8"), | |
"Date" -> Vector("Fri, 01 Apr 2016 12:37:33 GMT"), | |
"Status" -> Vector("HTTP/1.1 200 OK") | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment