Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1917 from Leammas/add_implicit_decoder
Implement optional implicit allowing usage of circe decoders without EntityDecoder definition
- Loading branch information
Showing
6 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.http4s.circe | ||
|
||
object CirceEntityCodec extends CirceEntityDecoder with CirceEntityEncoder |
14 changes: 14 additions & 0 deletions
14
circe/src/main/scala/org/http4s/circe/CirceEntityDecoder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.http4s.circe | ||
|
||
import cats.effect.Sync | ||
import io.circe.Decoder | ||
import org.http4s.EntityDecoder | ||
|
||
/** | ||
* Derive [[EntityDecoder]] if implicit [[Decoder]] is in the scope without need to explicitly call `jsonOf` | ||
*/ | ||
trait CirceEntityDecoder { | ||
implicit def circeEntityDecoder[F[_]: Sync, A: Decoder]: EntityDecoder[F, A] = jsonOf[F, A] | ||
} | ||
|
||
object CirceEntityDecoder extends CirceEntityDecoder |
15 changes: 15 additions & 0 deletions
15
circe/src/main/scala/org/http4s/circe/CirceEntityEncoder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.http4s.circe | ||
|
||
import cats.Applicative | ||
import io.circe.Encoder | ||
import org.http4s.EntityEncoder | ||
|
||
/** | ||
* Derive [[EntityEncoder]] if implicit [[Encoder]] is in the scope without need to explicitly call `jsonEncoderOf` | ||
*/ | ||
trait CirceEntityEncoder { | ||
implicit def circeEntityEncoder[F[_]: Applicative, A: Encoder]: EntityEncoder[F, A] = | ||
jsonEncoderOf[F, A] | ||
} | ||
|
||
object CirceEntityEncoder extends CirceEntityEncoder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters