From e74ade7ac9bfff9239c0243c0fdf01b18d4a0ec3 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 13 Aug 2018 21:11:11 +0800 Subject: 0.1.0 --- example/staticFiles/app/resources/cask/example.txt | 1 + example/staticFiles/app/src/StaticFiles.scala | 7 +++++-- example/staticFiles/app/test/src/ExampleTests.scala | 5 ++++- example/staticFiles/build.sc | 11 ++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 example/staticFiles/app/resources/cask/example.txt (limited to 'example/staticFiles') diff --git a/example/staticFiles/app/resources/cask/example.txt b/example/staticFiles/app/resources/cask/example.txt new file mode 100644 index 0000000..5184576 --- /dev/null +++ b/example/staticFiles/app/resources/cask/example.txt @@ -0,0 +1 @@ +the quick brown fox jumps over the lazy dog \ No newline at end of file diff --git a/example/staticFiles/app/src/StaticFiles.scala b/example/staticFiles/app/src/StaticFiles.scala index 4da9805..e47f0a1 100644 --- a/example/staticFiles/app/src/StaticFiles.scala +++ b/example/staticFiles/app/src/StaticFiles.scala @@ -5,8 +5,11 @@ object StaticFiles extends cask.MainRoutes{ "Hello!" } - @cask.static("/static") - def staticRoutes() = "cask/test/resources/cask" + @cask.staticFiles("/static/file") + def staticFileRoutes() = "app/resources/cask" + + @cask.staticResources("/static/resource") + def staticResourceRoutes() = "cask" initialize() } diff --git a/example/staticFiles/app/test/src/ExampleTests.scala b/example/staticFiles/app/test/src/ExampleTests.scala index ddf7de3..c60f443 100644 --- a/example/staticFiles/app/test/src/ExampleTests.scala +++ b/example/staticFiles/app/test/src/ExampleTests.scala @@ -19,7 +19,10 @@ object ExampleTests extends TestSuite{ val tests = Tests{ 'StaticFiles - test(StaticFiles){ host => - requests.get(s"$host/static/example.txt").text() ==> + requests.get(s"$host/static/file/example.txt").text() ==> + "the quick brown fox jumps over the lazy dog" + + requests.get(s"$host/static/resource/example.txt").text() ==> "the quick brown fox jumps over the lazy dog" } diff --git a/example/staticFiles/build.sc b/example/staticFiles/build.sc index 0e803b8..00a7ee3 100644 --- a/example/staticFiles/build.sc +++ b/example/staticFiles/build.sc @@ -4,9 +4,11 @@ import mill._, scalalib._ trait AppModule extends ScalaModule{ def scalaVersion = "2.12.6" def ivyDeps = Agg( - ivy"com.lihaoyi::cask:0.0.9", + ivy"com.lihaoyi::cask:0.1.0", ) + def forkWorkingDir = build.millSourcePath + object test extends Tests{ def testFrameworks = Seq("utest.runner.Framework") @@ -14,5 +16,12 @@ trait AppModule extends ScalaModule{ ivy"com.lihaoyi::utest::0.6.3", ivy"com.lihaoyi::requests::0.1.2", ) + + def forkWorkingDir = build.millSourcePath + + // redirect this to the forked `test` to make sure static file serving works + def testLocal(args: String*) = T.command{ + test(args:_*) + } } } \ No newline at end of file -- cgit v1.2.3