forked from Versal/scamper
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add asynchronous scalatra servlet and play2-mini server
- Loading branch information
1 parent
23d5e50
commit 34f3efe
Showing
15 changed files
with
118 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ target/ | |
bin/ | ||
project/target/ | ||
project/project/ | ||
dist/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name := "scamper-play2-mini" | ||
|
||
version := "0.1-SNAPSHOT" | ||
|
||
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" | ||
|
||
libraryDependencies += "com.typesafe" %% "play-mini" % "2.0.3" | ||
|
||
mainClass in (Compile, run) := Some("play.core.server.NettyServer") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
play { | ||
akka { | ||
actor { | ||
deployment { | ||
/actions { | ||
router = round-robin | ||
nr-of-instances = 100 | ||
} | ||
/promises { | ||
router = round-robin | ||
nr-of-instances = 100 | ||
} | ||
} | ||
retrieveBodyParserTimeout = 5 seconds | ||
actions-dispatcher = { | ||
fork-join-executor { | ||
parallelism-factor = 100 | ||
parallelism-max = 100 | ||
} | ||
} | ||
promises-dispatcher = { | ||
fork-join-executor { | ||
parallelism-factor = 100 | ||
parallelism-max = 100 | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import play.api.Configuration | ||
import com.typesafe.config.ConfigFactory | ||
|
||
object Global extends com.typesafe.play.mini.Setup(scamper.App) { | ||
override def configuration: Configuration = Configuration(ConfigFactory.load("application.conf")) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package scamper | ||
|
||
import com.typesafe.play.mini.Application | ||
import com.typesafe.play.mini.GET | ||
import com.typesafe.play.mini.Path | ||
|
||
import play.api.mvc.Action | ||
import play.api.mvc.PlainResult | ||
import play.api.mvc.ResponseHeader | ||
import play.api.mvc.SimpleResult | ||
|
||
object App extends Application { | ||
|
||
def route = { | ||
case GET(Path("/simple")) => simple() | ||
case GET(Path("/slow")) => slow() | ||
} | ||
|
||
protected def response(code: Int, body: String, `type`: String): PlainResult = { | ||
new SimpleResult[String](header = ResponseHeader(code), | ||
body = play.api.libs.iteratee.Enumerator(body)) | ||
.as(`type`) | ||
.withHeaders(("Access-Control-Allow-Origin", "*")) | ||
} | ||
|
||
def simple() = Action { implicit request => | ||
response(200, "<h1>simple</h1>", "text/html") | ||
} | ||
|
||
def slow() = Action { implicit request => | ||
val start = System.currentTimeMillis | ||
Thread.sleep(200) | ||
val stop = System.currentTimeMillis | ||
response(200, "<h1>slept for %d ms</h1>".format(stop - start), "text/html") | ||
} | ||
|
||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
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
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