-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# single line curl command | ||
curl http://localhost:8080/ping | ||
|
||
# multiline curl command | ||
curl -X POST \ | ||
http://localhost:8080/uuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("me.yceel" % "sbt-curl" % System.getProperty("plugin.version")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# start server | ||
> run | ||
# run curl commands in curl-test | ||
> curlTest |