Created
June 7, 2019 19:18
-
-
Save adamw/c2f54f8276d7d5657ad492c6724f3d13 to your computer and use it in GitHub Desktop.
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
package tapir.example | |
import org.http4s.{EntityBody, HttpRoutes} | |
import scalaz.zio.{IO, Task} | |
import tapir.Endpoint | |
import tapir.server.http4s.Http4sServerOptions | |
import scalaz.zio.interop.catz._ | |
import tapir.server.ServerEndpoint | |
package object zio { | |
implicit class ZioEndpoint[I, E, O](e: Endpoint[I, E, O, EntityBody[Task]]) { | |
def toZioRoutes(logic: I => IO[E, O])( | |
implicit serverOptions: Http4sServerOptions[Task]): HttpRoutes[Task] = { | |
import tapir.server.http4s._ | |
e.toRoutes(i => logic(i).either) | |
} | |
def zioServerLogic(logic: I => IO[E, O]): | |
ServerEndpoint[I, E, O, EntityBody[Task], Task] = | |
ServerEndpoint(e, logic(_).either) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment