Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robhinds/e56c5daa8a3c00efb0df54bda7661eb1 to your computer and use it in GitHub Desktop.
Save robhinds/e56c5daa8a3c00efb0df54bda7661eb1 to your computer and use it in GitHub Desktop.
trait DefaultResponseSerializerComponent extends ResponseSerializerComponent {
override def responseSerializer: ResponseSerializer = new ResponseSerializer {
override def serialiseResponse[B: Encoder](e: Either[ErrorResponse, B]): Json = e match {
case Left(x) => x.asJson
case Right(x) =>
Json.fromFields(List(
("status", Json.fromString("200")),
("data", x.asJson)
))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment