Created
April 29, 2021 11:19
-
-
Save Swoorup/6a79270d04caf77a3a185c90d35f6316 to your computer and use it in GitHub Desktop.
Scala 3 - Cats effect - Akka Http Marshalling
This file contains hidden or 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
import akka.http.scaladsl.marshalling.{GenericMarshallers, ToResponseMarshaller} | |
import cats.Id | |
import cats.effect.IO | |
import cats.effect.std.Dispatcher | |
import cats.syntax.apply.* | |
import scala.concurrent.Future | |
object FMarshaller: | |
given [A](using m: ToResponseMarshaller[A]): ToResponseMarshaller[Future[A]] = | |
GenericMarshallers.futureMarshaller | |
given [A](using dispatcher: Dispatcher[IO], m: ToResponseMarshaller[A]): ToResponseMarshaller[IO[A]] = | |
GenericMarshallers.futureMarshaller(m).compose(dispatcher.unsafeToFuture) | |
given [A](using m: ToResponseMarshaller[A]): ToResponseMarshaller[Id[A]] = m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment