summaryrefslogtreecommitdiff
path: root/cask/test
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-07-20 10:31:12 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-07-20 10:43:11 +0800
commitbb7dbd6a1b188f07b512057264177972d0dec850 (patch)
tree3005e706218d8f1f40ede824fe9d9a0c0bd8464e /cask/test
parent37bfff46d2d875d2dec27a24973ec8f6784f1bfb (diff)
downloadcask-bb7dbd6a1b188f07b512057264177972d0dec850.tar.gz
cask-bb7dbd6a1b188f07b512057264177972d0dec850.tar.bz2
cask-bb7dbd6a1b188f07b512057264177972d0dec850.zip
Simple routing & serving now works in the 3 test routes given
Diffstat (limited to 'cask/test')
-rw-r--r--cask/test/src/test/cask/CaskTest.scala26
1 files changed, 8 insertions, 18 deletions
diff --git a/cask/test/src/test/cask/CaskTest.scala b/cask/test/src/test/cask/CaskTest.scala
index a1384f8..9a0876d 100644
--- a/cask/test/src/test/cask/CaskTest.scala
+++ b/cask/test/src/test/cask/CaskTest.scala
@@ -1,34 +1,24 @@
package test.cask
+object MyServer extends cask.Routes{
-object MyServer extends cask.Server(){
- def x = "/ext"
- @cask.route("/user/:username" + (x * 2))
+ @cask.route("/user/:userName")
def showUserProfile(userName: String) = {
- // show the user profile for that user
s"User $userName"
}
- @cask.route("/post/:int")
- def showPost(postId: Int) = {
- // show the post with the given id, the id is an integer
- s"Post $postId"
+ @cask.route("/post/:postId")
+ def showPost(postId: Int, query: String) = {
+ s"Post $postId $query"
}
- @cask.route("/path/:subPath")
- def show_subpath(subPath: String) = {
- // show the subpath after /path/
+ @cask.route("/path/::subPath")
+ def showSubpath(subPath: String) = {
s"Subpath $subPath"
}
initialize()
- println(routes.value)
-}
-
-object Main extends cask.Main(MyServer){
- def main(args: Array[String]): Unit = {
- MyServer
- }
}
+object Main extends cask.Main(MyServer)