endpoints4s.algebra.circe

Members list

Type members

Classlikes

trait CirceCodec[A]

Combines both an io.circe.Encoder and a io.circe.Decoder into a single type class.

Combines both an io.circe.Encoder and a io.circe.Decoder into a single type class.

You don’t need to define instances by yourself as they can be derived from an existing pair of an io.circe.Encoder and a io.circe.Decoder.

Attributes

See also
Companion
object
Supertypes
class Object
trait Matchable
class Any
object CirceCodec

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
CirceCodec.type

Partial interpreter for endpoints4s.algebra.JsonEntitiesFromCodecs that only fixes the JsonCodec[A] type to a CirceCodec.

Partial interpreter for endpoints4s.algebra.JsonEntitiesFromCodecs that only fixes the JsonCodec[A] type to a CirceCodec.

The jsonRequest and jsonResponse operations have to be implemented by a more specialized interpreter.

Typical usage:

 /* shared MyDto.scala */

 case class MyDto(i: Int, s: String)

 object MyDto {
   import io.circe.{Encoder, Decoder}
   import io.circe.generic.semiauto.{deriveEncoder, deriveDecoder}

   implicit val encoder: Encoder[MyDto] = deriveEncoder
   implicit val decoder: Decoder[MyDto] = deriveDecoder
 }
 /* shared endpoint definition */

 trait MyEndpoints extends algebra.Endpoints with algebra.circe.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"))
   )

 }

Attributes

Supertypes
trait JsonCodecs
trait JsonEntities
trait Errors
trait Responses
trait StatusCodes
trait Requests
trait Methods
trait Urls
class Object
trait Matchable
class Any
Show all