Skip to content

Commit

Permalink
Add entity for json from Circe encoder / decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Jan 21, 2024
1 parent cedb4ad commit c0b52c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/shared/src/main/scala/krop/route/Entity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package krop.route

import cats.effect.IO
import io.circe.Json
import io.circe.{Decoder, Encoder, Json}
import org.http4s.DecodeResult
import org.http4s.EntityDecoder
import org.http4s.EntityEncoder
Expand Down Expand Up @@ -77,6 +77,12 @@ object Entity {
CirceEntityEncoder.circeEntityEncoder
)

def jsonOf[A: Encoder: Decoder]: InvariantEntity[A] =
Entity(
CirceEntityDecoder.circeEntityDecoder,
CirceEntityEncoder.circeEntityEncoder
)

val unit: InvariantEntity[Unit] =
Entity(
EntityDecoder.decodeBy[IO, Unit](MediaRange.`*/*`)(_ =>
Expand Down

0 comments on commit c0b52c9

Please sign in to comment.