endpoints4s.algebra.circe
package endpoints4s.algebra.circe
Members list
Type members
Classlikes
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 Objecttrait Matchableclass Any
object CirceCodec
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
CirceCodec.type
trait JsonEntitiesFromCodecs extends JsonEntitiesFromCodecs
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 JsonEntitiesFromCodecstrait JsonCodecstrait JsonEntitiestrait Errorstrait Responsestrait StatusCodestrait Requeststrait SemigroupalSyntaxtrait Methodstrait Urlstrait InvariantFunctorSyntaxclass Objecttrait Matchableclass AnyShow all
In this article