I am using akka http. In my API layer I have defined the following classes:
sealed abstract class ApiResponse[A](val content: A, val code: Int)
final case class Success[A](override val content: A, override val code: Int) extends ApiResponse(content, code)
final case class Failure[A](override val content: A, override val code: Int) extends ApiResponse(content, code)
I would like to have them marshalled into following jsons respectively:
{ "ok" : "true", "content" : "..." }
{ "ok" : "false", "content" : "..." }
And also I would like to have the code to be set as http status code in the response. I tried to define ToReponseMarshaller for this but got stuck, not sure if this is the correct choice for my problem.