diff --git a/src/sbt-test/sbt-curl/api/build.sbt b/src/sbt-test/sbt-curl/api/build.sbt new file mode 100644 index 0000000..1cd5fb6 --- /dev/null +++ b/src/sbt-test/sbt-curl/api/build.sbt @@ -0,0 +1,11 @@ +val AkkaHttpVersion = "10.5.3" + +lazy val root = (project in file(".")) + .settings( + version := "0.1", + resolvers += "Akka repo".at("https://repo.akka.io/maven"), + libraryDependencies ++= Seq( + "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion, + "com.typesafe.akka" %% "akka-stream" % "2.7.0" + ) + ) diff --git a/src/sbt-test/sbt-curl/api/curl-test b/src/sbt-test/sbt-curl/api/curl-test new file mode 100644 index 0000000..40b0795 --- /dev/null +++ b/src/sbt-test/sbt-curl/api/curl-test @@ -0,0 +1,6 @@ +# single line curl command +curl http://localhost:8080/ping + +# multiline curl command +curl -X POST \ +http://localhost:8080/uuid diff --git a/src/sbt-test/sbt-curl/api/project/plugins.sbt b/src/sbt-test/sbt-curl/api/project/plugins.sbt new file mode 100644 index 0000000..3a980d7 --- /dev/null +++ b/src/sbt-test/sbt-curl/api/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("me.yceel" % "sbt-curl" % System.getProperty("plugin.version")) diff --git a/src/sbt-test/sbt-curl/api/src/main/scala/Api.scala b/src/sbt-test/sbt-curl/api/src/main/scala/Api.scala new file mode 100644 index 0000000..417e501 --- /dev/null +++ b/src/sbt-test/sbt-curl/api/src/main/scala/Api.scala @@ -0,0 +1,28 @@ +import akka.actor.ActorSystem +import akka.http.scaladsl.Http +import akka.http.scaladsl.server.Directives + +import java.util.UUID + +object Api extends Directives { + def main(args: Array[String]): Unit = { + implicit val system = ActorSystem("api") + + val router = concat( + path("ping") { + get { + complete(200, "I'm up!") + } + }, + path("uuid") { + post { + val uuid = UUID.randomUUID() + complete(200, uuid.toString) + } + } + ) + + val port = sys.props.getOrElse("http.port", "8080").toInt + Http().newServerAt("0.0.0.0", port).bind(router) + } +} \ No newline at end of file diff --git a/src/sbt-test/sbt-curl/api/test b/src/sbt-test/sbt-curl/api/test new file mode 100644 index 0000000..83c8d80 --- /dev/null +++ b/src/sbt-test/sbt-curl/api/test @@ -0,0 +1,4 @@ +# start server +> run +# run curl commands in curl-test +> curlTest \ No newline at end of file