How can I complete akka-http response with different types based on future response? I am trying to do something like
implicit val textFormat = jsonFormat1(Text.apply)
implicit val userFormat = jsonFormat2(User.apply)
path(Segment) { id =>
get {
complete {
(fooActor ? GetUser(id)).map {
case n: NotFound => Text("Not Found")
case u: User => u
}
}
}
}
but I am getting
type mismatch , expected: ToResponseMarshable , actual Futue[Product with Serializable ]