diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-07-21 07:55:22 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-07-21 07:55:22 +0800 |
commit | 929967c84d5d6dee04247a5b2069e1d8b61f0369 (patch) | |
tree | 3cb4ef42d7465e2a2dca1f37219d91c65f57c99c /cask/test/src/test/cask | |
parent | c1d070cbdaba6a8f874f3f825f1c7881389fda14 (diff) | |
download | cask-929967c84d5d6dee04247a5b2069e1d8b61f0369.tar.gz cask-929967c84d5d6dee04247a5b2069e1d8b61f0369.tar.bz2 cask-929967c84d5d6dee04247a5b2069e1d8b61f0369.zip |
Flesh out Flask examples
Diffstat (limited to 'cask/test/src/test/cask')
-rw-r--r-- | cask/test/src/test/cask/HttpMethods.scala | 13 | ||||
-rw-r--r-- | cask/test/src/test/cask/MinimalApplication.scala (renamed from cask/test/src/test/cask/HelloWorld.scala) | 2 | ||||
-rw-r--r-- | cask/test/src/test/cask/VariableRoutes.scala | 20 |
3 files changed, 34 insertions, 1 deletions
diff --git a/cask/test/src/test/cask/HttpMethods.scala b/cask/test/src/test/cask/HttpMethods.scala new file mode 100644 index 0000000..7f2ab7c --- /dev/null +++ b/cask/test/src/test/cask/HttpMethods.scala @@ -0,0 +1,13 @@ +package test.cask + +import io.undertow.server.HttpServerExchange + +object HttpMethods extends cask.MainRoutes{ + @cask.route("/login", methods = Seq("GET", "POST")) + def login(exchange: HttpServerExchange) = { + if (exchange.getRequestMethod.equalToString("POST")) "do_the_login" + else "show_the_login_form" + } + + initialize() +} diff --git a/cask/test/src/test/cask/HelloWorld.scala b/cask/test/src/test/cask/MinimalApplication.scala index a4b441c..caa6184 100644 --- a/cask/test/src/test/cask/HelloWorld.scala +++ b/cask/test/src/test/cask/MinimalApplication.scala @@ -1,6 +1,6 @@ package test.cask -object HelloWorld extends cask.MainRoutes{ +object MinimalApplication extends cask.MainRoutes{ @cask.get("/") def hello() = { "Hello World!" diff --git a/cask/test/src/test/cask/VariableRoutes.scala b/cask/test/src/test/cask/VariableRoutes.scala new file mode 100644 index 0000000..e7415c6 --- /dev/null +++ b/cask/test/src/test/cask/VariableRoutes.scala @@ -0,0 +1,20 @@ +package test.cask + +object VariableRoutes extends cask.MainRoutes{ + @cask.get("/user/:userName") + def showUserProfile(userName: String) = { + s"User $userName" + } + + @cask.get("/post/:postId") + def showPost(postId: Int, query: Seq[String]) = { + s"Post $postId $query" + } + + @cask.get("/path/::subPath") + def showSubpath(subPath: String) = { + s"Subpath $subPath" + } + + initialize() +} |