Skip to content

Commit

Permalink
feat(core): Add circe codec for Path
Browse files Browse the repository at this point in the history
  • Loading branch information
rlemaitre committed Feb 17, 2024
1 parent 12e9fbe commit ac48e21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 5 additions & 0 deletions modules/core/src/main/scala/pillars/codec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import io.circe.Codec
import io.circe.Decoder
import io.circe.Encoder
import io.circe.derivation.Configuration
import java.nio.file.Path
import org.http4s.Uri
import scala.concurrent.duration.FiniteDuration
import scala.jdk.DurationConverters.*

object codec:

given Decoder[Path] = Decoder.decodeString.emap(t => Right(Path.of(t)))

given Encoder[Path] = Encoder.encodeString.contramap(_.toString)

given Decoder[Host] = Decoder.decodeString.emap(t => Host.fromString(t).toRight("Failed to parse Host"))

given Encoder[Host] = Encoder.encodeString.contramap(_.toString)
Expand Down
6 changes: 1 addition & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ object Dependencies {
"org.typelevel" %% "mouse" % "1.2.2"
)

val module: Seq[ModuleID] = Seq(
"io.github.classgraph" % "classgraph" % "4.8.165",
"com.outr" %% "moduload" % "1.1.7"
)
val model: Seq[ModuleID] = Seq(
"com.comcast" %% "ip4s-core" % "3.4.0",
"io.github.iltotore" %% "iron" % "2.4.0",
Expand Down Expand Up @@ -93,5 +89,5 @@ object Dependencies {
) ++ tests
val httpClient: Seq[ModuleID] = http4sClient ++ http4s ++ tests
val core: Seq[ModuleID] =
effect ++ module ++ json ++ tapir ++ http4sServer ++ model ++ commandLine ++ logging ++ observability ++ tests
effect ++ json ++ tapir ++ http4sServer ++ model ++ commandLine ++ logging ++ observability ++ tests
}

0 comments on commit ac48e21

Please sign in to comment.