summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-08-22 18:15:24 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-08-22 18:15:24 +0800
commitdfe179d66517ab60dc80a89e6d5d14dd20b3fa2f (patch)
tree1fc9331f337fb622217d9cddfb0b723c85e6a8ed
parentf3fe134973e06b7498403c2775b8cdd181139380 (diff)
downloadcask-dfe179d66517ab60dc80a89e6d5d14dd20b3fa2f.tar.gz
cask-dfe179d66517ab60dc80a89e6d5d14dd20b3fa2f.tar.bz2
cask-dfe179d66517ab60dc80a89e6d5d14dd20b3fa2f.zip
0.1.30.1.3
-rw-r--r--.travis.yml2
-rw-r--r--build.sc7
-rw-r--r--docs/pages/1 - Cask: a Scala HTTP micro-framework.md21
-rw-r--r--example/compress/build.sc2
-rw-r--r--example/compress2/build.sc2
-rw-r--r--example/compress3/build.sc2
-rw-r--r--example/cookies/build.sc2
-rw-r--r--example/decorated/build.sc2
-rw-r--r--example/decorated2/build.sc2
-rw-r--r--example/endpoints/build.sc2
-rw-r--r--example/formJsonPost/build.sc2
-rw-r--r--example/httpMethods/build.sc2
-rw-r--r--example/minimalApplication/build.sc2
-rw-r--r--example/minimalApplication2/build.sc2
-rw-r--r--example/redirectAbort/build.sc2
-rw-r--r--example/scalatags/build.sc2
-rw-r--r--example/staticFiles/build.sc2
-rw-r--r--example/todo/build.sc2
-rw-r--r--example/todoApi/build.sc2
-rw-r--r--example/todoDb/build.sc2
-rw-r--r--example/twirl/app/src/Twirl.scala9
-rw-r--r--example/twirl/app/test/src/ExampleTests.scala29
-rw-r--r--example/twirl/app/views/hello.scala.html7
-rw-r--r--example/twirl/build.sc23
-rw-r--r--example/variableRoutes/build.sc2
-rw-r--r--example/websockets/build.sc2
26 files changed, 111 insertions, 25 deletions
diff --git a/.travis.yml b/.travis.yml
index d498846..ddc5cb6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,7 +20,7 @@ matrix:
jdk: oraclejdk8
script:
- - curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-11-1287d7 && chmod +x ~/bin/mill
+ - curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-19-807e47 && chmod +x ~/bin/mill
- export PATH=~/bin/mill:$PATH
- "$CI_SCRIPT"
diff --git a/build.sc b/build.sc
index b785054..40788bc 100644
--- a/build.sc
+++ b/build.sc
@@ -18,6 +18,7 @@ import $file.example.staticFiles.build
import $file.example.todo.build
import $file.example.todoApi.build
import $file.example.todoDb.build
+import $file.example.twirl.build
import $file.example.variableRoutes.build
import $file.example.websockets.build
@@ -50,7 +51,7 @@ object cask extends ScalaModule with PublishModule {
def testFrameworks = Seq("utest.runner.Framework")
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
ivy"org.xerial:sqlite-jdbc:3.18.0",
ivy"io.getquill::quill-jdbc:2.5.4"
)
@@ -80,6 +81,7 @@ object example extends Module{
object todo extends $file.example.todo.build.AppModule with LocalModule
object todoApi extends $file.example.todoApi.build.AppModule with LocalModule
object todoDb extends $file.example.todoDb.build.AppModule with LocalModule
+ object twirl extends $file.example.twirl.build.AppModule with LocalModule
object variableRoutes extends $file.example.variableRoutes.build.AppModule with LocalModule
object websockets extends $file.example.websockets.build.AppModule with LocalModule
}
@@ -122,6 +124,7 @@ def uploadToGithub(authKey: String) = T.command{
$file.example.todo.build.millSourcePath,
$file.example.todoApi.build.millSourcePath,
$file.example.todoDb.build.millSourcePath,
+ $file.example.twirl.build.millSourcePath,
$file.example.variableRoutes.build.millSourcePath,
$file.example.websockets.build.millSourcePath,
)
@@ -136,7 +139,7 @@ def uploadToGithub(authKey: String) = T.command{
|if [ ! -f out/mill-cask ]; then
| echo "Initializing Cask/Mill build tool for the first time"
| mkdir -p out &&
- | (echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-13-b9b133) > out/mill-cask
+ | (echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6-19-807e47) > out/mill-cask
|fi
|
|chmod +x out/mill-cask
diff --git a/docs/pages/1 - Cask: a Scala HTTP micro-framework.md b/docs/pages/1 - Cask: a Scala HTTP micro-framework.md
index dd98dd2..b454d0a 100644
--- a/docs/pages/1 - Cask: a Scala HTTP micro-framework.md
+++ b/docs/pages/1 - Cask: a Scala HTTP micro-framework.md
@@ -81,10 +81,10 @@ via the following coordinates:
```scala
// Mill
-ivy"com.lihaoyi::cask:0.1.1"
+ivy"com.lihaoyi::cask:0.1.3"
// SBT
-"com.lihaoyi" %% "cask" % "0.1.1"
+"com.lihaoyi" %% "cask" % "0.1.3"
```
The `./cask` command is just a wrapper around the
@@ -222,7 +222,22 @@ adding the relevant `ivy"com.lihaoyi::scalatags:0.6.7"` dependency to your
$$$scalatags
-
+If you prefer to use the
+[Twirl](https://www.playframework.com/documentation/2.6.x/ScalaTemplates)
+templating engine, you can use that too:
+
+$$$twirl
+
+With the following `app/views/hello.scala.html`:
+```html
+@(titleTxt: String)
+<html>
+ <body>
+ <h1>@titleTxt</h1>
+ <p>I am cow</p>
+ </body>
+</html>
+```
## Extending Endpoints with Decorators
diff --git a/example/compress/build.sc b/example/compress/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/compress/build.sc
+++ b/example/compress/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/compress2/build.sc b/example/compress2/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/compress2/build.sc
+++ b/example/compress2/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/compress3/build.sc b/example/compress3/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/compress3/build.sc
+++ b/example/compress3/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/cookies/build.sc b/example/cookies/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/cookies/build.sc
+++ b/example/cookies/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/decorated/build.sc b/example/decorated/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/decorated/build.sc
+++ b/example/decorated/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/decorated2/build.sc b/example/decorated2/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/decorated2/build.sc
+++ b/example/decorated2/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/endpoints/build.sc b/example/endpoints/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/endpoints/build.sc
+++ b/example/endpoints/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/formJsonPost/build.sc b/example/formJsonPost/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/formJsonPost/build.sc
+++ b/example/formJsonPost/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/httpMethods/build.sc b/example/httpMethods/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/httpMethods/build.sc
+++ b/example/httpMethods/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/minimalApplication/build.sc b/example/minimalApplication/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/minimalApplication/build.sc
+++ b/example/minimalApplication/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/minimalApplication2/build.sc b/example/minimalApplication2/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/minimalApplication2/build.sc
+++ b/example/minimalApplication2/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/redirectAbort/build.sc b/example/redirectAbort/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/redirectAbort/build.sc
+++ b/example/redirectAbort/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/scalatags/build.sc b/example/scalatags/build.sc
index 86141e0..12e8ff9 100644
--- a/example/scalatags/build.sc
+++ b/example/scalatags/build.sc
@@ -13,7 +13,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/staticFiles/build.sc b/example/staticFiles/build.sc
index 54d1fb5..4f4716d 100644
--- a/example/staticFiles/build.sc
+++ b/example/staticFiles/build.sc
@@ -14,7 +14,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
def forkWorkingDir = build.millSourcePath
diff --git a/example/todo/build.sc b/example/todo/build.sc
index 0f01a14..37e5253 100644
--- a/example/todo/build.sc
+++ b/example/todo/build.sc
@@ -15,7 +15,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/todoApi/build.sc b/example/todoApi/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/todoApi/build.sc
+++ b/example/todoApi/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/todoDb/build.sc b/example/todoDb/build.sc
index 5bfc599..52ac761 100644
--- a/example/todoDb/build.sc
+++ b/example/todoDb/build.sc
@@ -14,7 +14,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/twirl/app/src/Twirl.scala b/example/twirl/app/src/Twirl.scala
new file mode 100644
index 0000000..f6f12b4
--- /dev/null
+++ b/example/twirl/app/src/Twirl.scala
@@ -0,0 +1,9 @@
+package app
+object Twirl extends cask.MainRoutes{
+ @cask.get("/")
+ def hello() = {
+ "<!doctype html>" + html.hello("Hello World")
+ }
+
+ initialize()
+}
diff --git a/example/twirl/app/test/src/ExampleTests.scala b/example/twirl/app/test/src/ExampleTests.scala
new file mode 100644
index 0000000..815f656
--- /dev/null
+++ b/example/twirl/app/test/src/ExampleTests.scala
@@ -0,0 +1,29 @@
+package app
+import io.undertow.Undertow
+
+import utest._
+
+object ExampleTests extends TestSuite{
+ def test[T](example: cask.main.BaseMain)(f: String => T): T = {
+ val server = Undertow.builder
+ .addHttpListener(8080, "localhost")
+ .setHandler(example.defaultHandler)
+ .build
+ server.start()
+ val res =
+ try f("http://localhost:8080")
+ finally server.stop()
+ res
+ }
+
+ val tests = Tests {
+ 'Twirl - test(Twirl) { host =>
+ val body = requests.get(host).text()
+
+ assert(
+ body.contains("<h1>Hello World</h1>"),
+ body.contains("<p>I am cow</p>"),
+ )
+ }
+ }
+}
diff --git a/example/twirl/app/views/hello.scala.html b/example/twirl/app/views/hello.scala.html
new file mode 100644
index 0000000..604a8f4
--- /dev/null
+++ b/example/twirl/app/views/hello.scala.html
@@ -0,0 +1,7 @@
+@(titleTxt: String)
+<html>
+ <body>
+ <h1>@titleTxt</h1>
+ <p>I am cow</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/example/twirl/build.sc b/example/twirl/build.sc
new file mode 100644
index 0000000..8e95a19
--- /dev/null
+++ b/example/twirl/build.sc
@@ -0,0 +1,23 @@
+import mill._, scalalib._
+import $ivy.`com.lihaoyi::mill-contrib-twirllib:0.2.6-18-b29c13`
+
+trait AppModule extends ScalaModule with mill.twirllib.TwirlModule{
+ def scalaVersion = "2.12.6"
+ def twirlVersion = "1.3.15"
+
+ def generatedSources = T{ Seq(compileTwirl().classes) }
+ def ivyDeps = Agg(
+ ivy"com.lihaoyi::cask:0.1.1",
+ ivy"com.lihaoyi::scalatags:0.6.7",
+ ivy"com.typesafe.play::twirl-api:${twirlVersion()}",
+ )
+
+ object test extends Tests{
+ def testFrameworks = Seq("utest.runner.Framework")
+
+ def ivyDeps = Agg(
+ ivy"com.lihaoyi::utest::0.6.3",
+ ivy"com.lihaoyi::requests::0.1.3",
+ )
+ }
+} \ No newline at end of file
diff --git a/example/variableRoutes/build.sc b/example/variableRoutes/build.sc
index a08b2c6..e5faf4b 100644
--- a/example/variableRoutes/build.sc
+++ b/example/variableRoutes/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
)
}
} \ No newline at end of file
diff --git a/example/websockets/build.sc b/example/websockets/build.sc
index aa9fa17..ef595b1 100644
--- a/example/websockets/build.sc
+++ b/example/websockets/build.sc
@@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.6.3",
- ivy"com.lihaoyi::requests::0.1.2",
+ ivy"com.lihaoyi::requests::0.1.3",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)
}