diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-07-22 01:53:26 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-07-22 01:53:26 +0800 |
commit | 48b60ea02268b060f859101a41fee5394925237a (patch) | |
tree | 69a0c3336e17d6367f7839de632464aee7799b91 /cask/test | |
parent | cc42c8dd9778862c8a0eb10c0e5051409a105666 (diff) | |
download | cask-48b60ea02268b060f859101a41fee5394925237a.tar.gz cask-48b60ea02268b060f859101a41fee5394925237a.tar.bz2 cask-48b60ea02268b060f859101a41fee5394925237a.zip |
File uploads and cookies now work
Diffstat (limited to 'cask/test')
-rw-r--r-- | cask/test/src/test/cask/Cookies.scala | 22 | ||||
-rw-r--r-- | cask/test/src/test/cask/FileUploads.scala | 16 |
2 files changed, 38 insertions, 0 deletions
diff --git a/cask/test/src/test/cask/Cookies.scala b/cask/test/src/test/cask/Cookies.scala new file mode 100644 index 0000000..9b32f25 --- /dev/null +++ b/cask/test/src/test/cask/Cookies.scala @@ -0,0 +1,22 @@ +package test.cask + +import io.undertow.server.handlers.CookieImpl + +object Cookies extends cask.MainRoutes{ + @cask.get("/read-cookies") + def readCookies(cookies: cask.Cookies) = { + val username = cookies.value.get("username") + username.map(_.getValue).toString + } + + @cask.get("store-cookies") + def storeCookies() = { + cask.Response( + "Cookies Set!", + cookies = Seq(new CookieImpl("username", "the username")) + ) + } + + initialize() +} + diff --git a/cask/test/src/test/cask/FileUploads.scala b/cask/test/src/test/cask/FileUploads.scala new file mode 100644 index 0000000..e56be2d --- /dev/null +++ b/cask/test/src/test/cask/FileUploads.scala @@ -0,0 +1,16 @@ +package test.cask + +import io.undertow.server.HttpServerExchange +import io.undertow.server.handlers.form.FormData + +object FileUploads extends cask.MainRoutes{ + // curl -F "image=@build.sc" localhost:8080/upload + @cask.post("/upload") + def uploadFile(exchange: HttpServerExchange, formData: FormData) = { + val file = formData.getFirst("image") + file.getPath.toString + } + + initialize() +} + |