From a43556851bf986b81351fc9f1ae5ba51bf21dc47 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Thu, 11 Oct 2018 14:19:28 -0700 Subject: Add an example to the README and a standalone application template --- documentation/example/.gitignore | 1 + documentation/example/build.sbt | 6 ++++++ documentation/example/project/build.properties | 1 + documentation/example/project/plugins.sbt | 1 + .../example/src/main/scala/example/Main.scala | 21 +++++++++++++++++++++ 5 files changed, 30 insertions(+) create mode 100644 documentation/example/.gitignore create mode 100644 documentation/example/build.sbt create mode 100644 documentation/example/project/build.properties create mode 100644 documentation/example/project/plugins.sbt create mode 100644 documentation/example/src/main/scala/example/Main.scala (limited to 'documentation/example') diff --git a/documentation/example/.gitignore b/documentation/example/.gitignore new file mode 100644 index 0000000..2157ef4 --- /dev/null +++ b/documentation/example/.gitignore @@ -0,0 +1 @@ +.data-* diff --git a/documentation/example/build.sbt b/documentation/example/build.sbt new file mode 100644 index 0000000..d2bd592 --- /dev/null +++ b/documentation/example/build.sbt @@ -0,0 +1,6 @@ +lazy val `example-app` = project + .in(file(".")) + .enablePlugins(ServicePlugin) + .settings( + libraryDependencies += "xyz.driver" %% "core-init" % "2.0.0-M5" + ) diff --git a/documentation/example/project/build.properties b/documentation/example/project/build.properties new file mode 100644 index 0000000..0cd8b07 --- /dev/null +++ b/documentation/example/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.2.3 diff --git a/documentation/example/project/plugins.sbt b/documentation/example/project/plugins.sbt new file mode 100644 index 0000000..53be881 --- /dev/null +++ b/documentation/example/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("xyz.driver" % "sbt-settings" % "2.0.12") diff --git a/documentation/example/src/main/scala/example/Main.scala b/documentation/example/src/main/scala/example/Main.scala new file mode 100644 index 0000000..2548f79 --- /dev/null +++ b/documentation/example/src/main/scala/example/Main.scala @@ -0,0 +1,21 @@ +package example + +import xyz.driver.core.init + +object Main extends init.SimpleHttpApp { + + lazy val fs = this.storage("data") + + override def applicationRoute = path("data" / Segment) { key => + post { + entity(as[Array[Byte]]) { value => + complete(fs.uploadContent(key, value)) + } + } ~ get { + rejectEmptyResponse{ + complete(fs.content(key)) + } + } + } + +} -- cgit v1.2.3