summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2019-09-15 13:11:17 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2019-09-15 13:19:12 +0800
commitf158811a79f702a406e3dd2b961f3b085e6c47c0 (patch)
tree190d0b7eb7d3ea4bcfb7364bd8c73fa5315c966b /example
parent0e098a93da94c251eb05d42bc7ef48394600508c (diff)
downloadcask-f158811a79f702a406e3dd2b961f3b085e6c47c0.tar.gz
cask-f158811a79f702a406e3dd2b961f3b085e6c47c0.tar.bz2
cask-f158811a79f702a406e3dd2b961f3b085e6c47c0.zip
Sketch out a standard `cask.Logger` interface and standardize dependency injection via case class implicits
Diffstat (limited to 'example')
-rw-r--r--example/compress/app/test/src/ExampleTests.scala2
-rw-r--r--example/compress2/app/src/Compress2.scala8
-rw-r--r--example/compress2/app/test/src/ExampleTests.scala2
-rw-r--r--example/compress3/app/src/Compress3.scala7
-rw-r--r--example/compress3/app/test/src/ExampleTests.scala5
-rw-r--r--example/cookies/app/test/src/ExampleTests.scala2
-rw-r--r--example/decorated/app/test/src/ExampleTests.scala2
-rw-r--r--example/decorated2/app/test/src/ExampleTests.scala2
-rw-r--r--example/endpoints/app/test/src/ExampleTests.scala2
-rw-r--r--example/formJsonPost/app/test/src/ExampleTests.scala2
-rw-r--r--example/httpMethods/app/test/src/ExampleTests.scala2
-rw-r--r--example/minimalApplication/app/test/src/ExampleTests.scala2
-rw-r--r--example/minimalApplication2/app/src/MinimalApplication2.scala8
-rw-r--r--example/minimalApplication2/app/test/src/ExampleTests.scala4
-rw-r--r--example/redirectAbort/app/test/src/ExampleTests.scala2
-rw-r--r--example/scalatags/app/test/src/ExampleTests.scala2
-rw-r--r--example/staticFiles/app/test/src/ExampleTests.scala2
-rw-r--r--example/todoApi/app/test/src/ExampleTests.scala2
-rw-r--r--example/twirl/app/test/src/ExampleTests.scala2
-rw-r--r--example/variableRoutes/app/test/src/ExampleTests.scala2
-rw-r--r--example/websockets/app/test/src/ExampleTests.scala2
-rw-r--r--example/websockets2/app/test/src/ExampleTests.scala2
22 files changed, 39 insertions, 27 deletions
diff --git a/example/compress/app/test/src/ExampleTests.scala b/example/compress/app/test/src/ExampleTests.scala
index cd4d8d0..68c249f 100644
--- a/example/compress/app/test/src/ExampleTests.scala
+++ b/example/compress/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/compress2/app/src/Compress2.scala b/example/compress2/app/src/Compress2.scala
index 1a4cf69..b0deaa0 100644
--- a/example/compress2/app/src/Compress2.scala
+++ b/example/compress2/app/src/Compress2.scala
@@ -1,6 +1,8 @@
package app
-object Compress2 extends cask.Routes{
+import cask.util.Logger
+
+case class Compress2()(implicit val log: Logger) extends cask.Routes{
override def decorators = Seq(new cask.decorators.compress())
@cask.get("/")
@@ -11,4 +13,6 @@ object Compress2 extends cask.Routes{
initialize()
}
-object Compress2Main extends cask.Main(Compress2) \ No newline at end of file
+object Compress2Main extends cask.Main{
+ val allRoutes = Seq(Compress2())
+}
diff --git a/example/compress2/app/test/src/ExampleTests.scala b/example/compress2/app/test/src/ExampleTests.scala
index 9f9b4b3..fdfedda 100644
--- a/example/compress2/app/test/src/ExampleTests.scala
+++ b/example/compress2/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/compress3/app/src/Compress3.scala b/example/compress3/app/src/Compress3.scala
index 4d4df99..95bd851 100644
--- a/example/compress3/app/src/Compress3.scala
+++ b/example/compress3/app/src/Compress3.scala
@@ -1,6 +1,8 @@
package app
-object Compress3 extends cask.Routes{
+import cask.util.Logger
+
+case class Compress3()(implicit val log: Logger) extends cask.Routes{
@cask.get("/")
def hello() = {
@@ -10,6 +12,7 @@ object Compress3 extends cask.Routes{
initialize()
}
-object Compress3Main extends cask.Main(Compress3){
+object Compress3Main extends cask.Main{
override def mainDecorators = Seq(new cask.decorators.compress())
+ val allRoutes = Seq(Compress3())
} \ No newline at end of file
diff --git a/example/compress3/app/test/src/ExampleTests.scala b/example/compress3/app/test/src/ExampleTests.scala
index 88e1cbf..2bd8b31 100644
--- a/example/compress3/app/test/src/ExampleTests.scala
+++ b/example/compress3/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
@@ -20,8 +20,9 @@ object ExampleTests extends TestSuite{
test("Compress3Main") - withServer(Compress3Main){ host =>
val expected = "Hello World! Hello World! Hello World!"
requests.get(s"$host").text() ==> expected
+ val compressed = requests.get(s"$host", autoDecompress = false).text()
assert(
- requests.get(s"$host", autoDecompress = false).text().length < expected.length
+ compressed.length < expected.length
)
}
diff --git a/example/cookies/app/test/src/ExampleTests.scala b/example/cookies/app/test/src/ExampleTests.scala
index 150f59a..5954e35 100644
--- a/example/cookies/app/test/src/ExampleTests.scala
+++ b/example/cookies/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/decorated/app/test/src/ExampleTests.scala b/example/decorated/app/test/src/ExampleTests.scala
index c2c19a6..f6c8d01 100644
--- a/example/decorated/app/test/src/ExampleTests.scala
+++ b/example/decorated/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/decorated2/app/test/src/ExampleTests.scala b/example/decorated2/app/test/src/ExampleTests.scala
index 4343097..624b86d 100644
--- a/example/decorated2/app/test/src/ExampleTests.scala
+++ b/example/decorated2/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/endpoints/app/test/src/ExampleTests.scala b/example/endpoints/app/test/src/ExampleTests.scala
index 3314f24..a604f2f 100644
--- a/example/endpoints/app/test/src/ExampleTests.scala
+++ b/example/endpoints/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/formJsonPost/app/test/src/ExampleTests.scala b/example/formJsonPost/app/test/src/ExampleTests.scala
index 4178497..768220c 100644
--- a/example/formJsonPost/app/test/src/ExampleTests.scala
+++ b/example/formJsonPost/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/httpMethods/app/test/src/ExampleTests.scala b/example/httpMethods/app/test/src/ExampleTests.scala
index 30fa87f..40756a5 100644
--- a/example/httpMethods/app/test/src/ExampleTests.scala
+++ b/example/httpMethods/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/minimalApplication/app/test/src/ExampleTests.scala b/example/minimalApplication/app/test/src/ExampleTests.scala
index 1cda7a6..4ae6095 100644
--- a/example/minimalApplication/app/test/src/ExampleTests.scala
+++ b/example/minimalApplication/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/minimalApplication2/app/src/MinimalApplication2.scala b/example/minimalApplication2/app/src/MinimalApplication2.scala
index e537ea6..41ca55f 100644
--- a/example/minimalApplication2/app/src/MinimalApplication2.scala
+++ b/example/minimalApplication2/app/src/MinimalApplication2.scala
@@ -1,6 +1,8 @@
package app
-object MinimalRoutes extends cask.Routes{
+import cask.util.Logger
+
+case class MinimalRoutes()(implicit val log: Logger) extends cask.Routes{
@cask.get("/")
def hello() = {
"Hello World!"
@@ -13,4 +15,6 @@ object MinimalRoutes extends cask.Routes{
initialize()
}
-object MinimalMain extends cask.Main(MinimalRoutes) \ No newline at end of file
+object MinimalRoutesMain extends cask.Main{
+ val allRoutes = Seq(MinimalRoutes())
+} \ No newline at end of file
diff --git a/example/minimalApplication2/app/test/src/ExampleTests.scala b/example/minimalApplication2/app/test/src/ExampleTests.scala
index 4e5621c..a77c490 100644
--- a/example/minimalApplication2/app/test/src/ExampleTests.scala
+++ b/example/minimalApplication2/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
@@ -17,7 +17,7 @@ object ExampleTests extends TestSuite{
}
val tests = Tests{
- test("MinimalApplication2") - withServer(MinimalMain){ host =>
+ test("MinimalApplication2") - withServer(MinimalRoutesMain){ host =>
val success = requests.get(host)
success.text() ==> "Hello World!"
diff --git a/example/redirectAbort/app/test/src/ExampleTests.scala b/example/redirectAbort/app/test/src/ExampleTests.scala
index a4d149f..d87d24a 100644
--- a/example/redirectAbort/app/test/src/ExampleTests.scala
+++ b/example/redirectAbort/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/scalatags/app/test/src/ExampleTests.scala b/example/scalatags/app/test/src/ExampleTests.scala
index 53bc1ea..d4dfbb3 100644
--- a/example/scalatags/app/test/src/ExampleTests.scala
+++ b/example/scalatags/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/staticFiles/app/test/src/ExampleTests.scala b/example/staticFiles/app/test/src/ExampleTests.scala
index ebda8a0..8b74d19 100644
--- a/example/staticFiles/app/test/src/ExampleTests.scala
+++ b/example/staticFiles/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/todoApi/app/test/src/ExampleTests.scala b/example/todoApi/app/test/src/ExampleTests.scala
index 4e85a8e..f65f083 100644
--- a/example/todoApi/app/test/src/ExampleTests.scala
+++ b/example/todoApi/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/twirl/app/test/src/ExampleTests.scala b/example/twirl/app/test/src/ExampleTests.scala
index 2c445fb..0dcc120 100644
--- a/example/twirl/app/test/src/ExampleTests.scala
+++ b/example/twirl/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/variableRoutes/app/test/src/ExampleTests.scala b/example/variableRoutes/app/test/src/ExampleTests.scala
index 1755dea..93673d9 100644
--- a/example/variableRoutes/app/test/src/ExampleTests.scala
+++ b/example/variableRoutes/app/test/src/ExampleTests.scala
@@ -4,7 +4,7 @@ import io.undertow.Undertow
import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/websockets/app/test/src/ExampleTests.scala b/example/websockets/app/test/src/ExampleTests.scala
index a463824..d4d96da 100644
--- a/example/websockets/app/test/src/ExampleTests.scala
+++ b/example/websockets/app/test/src/ExampleTests.scala
@@ -8,7 +8,7 @@ import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = io.undertow.Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)
diff --git a/example/websockets2/app/test/src/ExampleTests.scala b/example/websockets2/app/test/src/ExampleTests.scala
index 27bff5e..96dfd7e 100644
--- a/example/websockets2/app/test/src/ExampleTests.scala
+++ b/example/websockets2/app/test/src/ExampleTests.scala
@@ -8,7 +8,7 @@ import utest._
object ExampleTests extends TestSuite{
- def withServer[T](example: cask.main.BaseMain)(f: String => T): T = {
+ def withServer[T](example: cask.main.Main)(f: String => T): T = {
val server = io.undertow.Undertow.builder
.addHttpListener(8080, "localhost")
.setHandler(example.defaultHandler)