- Akka Http version: "com.typesafe.akka" %% "akka-http" % "10.0.11"
- Stream version: "com.typesafe.akka" %% "akka-stream" % "2.5.7"
- Play Json version: "com.typesafe.play" %% "play-json" % "2.6.7"
I have the following method in the crudService:
def getAll: Future[Seq[A]]
I want to return this in a route to provide the outcome as Json to the world. I currently have this:
val crudService = new CrudService[Todo]()
val route =
pathPrefix("todo" / "_all") {
get {
complete {
crudService.getAll
}
}
}
val bindingFuture = Http().bindAndHandle(route, hostname, port)
I have also tried this (first complete the Future):
val route =
pathPrefix("todo" / "_all") {
get {
onSuccess(crudService.getAll) { x =>
complete x
}
}
}
It keeps saying: Not applicable to ToResponseMarshallable. I can't find documentation that leads to a correct solution and I don't understand exactly the problem here. Can somebody help out?