diff options
Diffstat (limited to 'example/staticFiles')
-rw-r--r-- | example/staticFiles/app/resources/cask/example.txt | 1 | ||||
-rw-r--r-- | example/staticFiles/app/src/StaticFiles.scala | 7 | ||||
-rw-r--r-- | example/staticFiles/app/test/src/ExampleTests.scala | 5 | ||||
-rw-r--r-- | example/staticFiles/build.sc | 11 |
4 files changed, 20 insertions, 4 deletions
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 |