Guest User

Untitled

a guest
Nov 20th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import akka.actor.ActorSystem
  2. import akka.http.scaladsl.Http
  3. import akka.http.scaladsl.server.Directives
  4. import akka.stream.{ ActorMaterializer, Materializer }
  5. import scala.io.StdIn
  6.  
  7. object ExampleApp {
  8.  
  9. private final case class Foo(bar: String, baz: Boolean = false)
  10.  
  11. def main(args: Array[String]): Unit = {
  12. implicit val system = ActorSystem()
  13. implicit val mat = ActorMaterializer()
  14.  
  15. Http().bindAndHandle(route, "127.0.0.1", 8000)
  16.  
  17. StdIn.readLine("Hit ENTER to exit")
  18. system.terminate()
  19. }
  20.  
  21. private def route(implicit mat: Materializer) = {
  22. import Directives._
  23. import FailFastCirceSupport._
  24. import io.circe.generic.auto._
  25.  
  26. pathSingleSlash {
  27. post {
  28. entity(as[Foo]) { foo =>
  29. complete {
  30. foo
  31. }
  32. }
  33. }
  34. }
  35. }
  36. }
Add Comment
Please, Sign In to add comment