Last active
December 2, 2019 11:42
-
-
Save markhatton/17b586982f1beab30425 to your computer and use it in GitHub Desktop.
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
/* | |
* 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