endpoints.algebra
Partial interpreter for endpoints.algebra.JsonEntitiesFromCodec that only fixes the JsonCodec[A] type to Play’s Format[A].
JsonCodec[A]
Format[A]
The jsonRequest and jsonResponse operations have to be implemented by a more specialized interpreter.
jsonRequest
jsonResponse
Typical usage:
/* shared MyDto.scala */ case class MyDto(i: Int, s: String) object MyDto { import play.api.libs.{Format, Json} implicit val jsonFormat: Format[MyDto] = Json.format[MyDto] }
/* shared endpoint definition */ trait MyEndpoints extends algebra.Endpoints with algebra.playjson.JsonEntitiesFromCodec { val myEndpoint = endpoint(get(path), jsonResponse[MyDto]) }
/* client MyEndpointsClient.scala */ object MyEndpointsClient extends MyEndpoints with xhr.JsonEntitiesFromCodec with xhr.faithful.Endpoints MyEndpointsClient.myEndpoint().map(myDto => println(myDto.i))
/* server MyEndpointsServer.scala */ object MyEndpointsServer extends MyEndpoints with play.server.JsonEntitiesFromCodec { val routes = routesFromEndpoints( myEndpoint.implementedBy(_ => MyDto(42, "foo")) ) }
Partial interpreter for endpoints.algebra.JsonEntitiesFromCodec that only fixes the
JsonCodec[A]
type to Play’sFormat[A]
.The
jsonRequest
andjsonResponse
operations have to be implemented by a more specialized interpreter.Typical usage: