Skip to content

Instantly share code, notes, and snippets.

@markhatton
Last active December 2, 2019 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhatton/17b586982f1beab30425 to your computer and use it in GitHub Desktop.
Save markhatton/17b586982f1beab30425 to your computer and use it in GitHub Desktop.
/*
* Akka HTTP route example
* in response to https://groups.google.com/forum/#!topic/akka-user/TVqM6bguX0A
*/
import akka.actor.ActorSystem
import akka.http.Http
import akka.http.model.StatusCodes
import akka.http.server._
import akka.http.server.Directives._
import akka.stream.ActorFlowMaterializer
import akka.stream.scaladsl.Sink
implicit val actorSystem = ActorSystem()
import actorSystem.dispatcher
implicit val actorFlowMaterializer = ActorFlowMaterializer()
val route = path("saveTsta")(
post(
entity(as[String]){
json =>
System.out.println(json)
complete(StatusCodes.OK)
}
)
)
val server = Http().bind("localhost", 8080)
val bindingFuture = server.to(Sink.foreach { conn =>
conn handleWith route
}).run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment