tapir
tapir copied to clipboard
[improvement] zio-http integration not comfortable failed effect usages
Tapir version: 0.19.3
From contract programming all looks good, but it becomes quite uncomfortable with latest update
zio-http integration not comfortable failed effect usages
Exsisting tapir library code ` implicit class RichZEndpoint[A, I, E, O, C](e: Endpoint[A, I, E, O, C]) {
def zServerLogic[R](logic: I => ZIO[R, E, O])(implicit aIsUnit: A =:= Unit): ZServerEndpoint[R, C] =
ServerEndpoint.public(e.asInstanceOf[Endpoint[Unit, I, E, O, C]], _ => logic(_: I).either.resurrect)
def zServerSecurityLogic[R, U](f: A => ZIO[R, E, U]): ZPartialServerEndpoint[R, A, U, I, E, O, C] =
ZPartialServerEndpoint(e, f)
}`
See logic ZIO[_ , E, _] contract forces to be with same error channel as Endpoint E if endpoint don't declare error E is Unit and clients can not use Task[O] and have manually describe in all places InternalServerError
Would you prefer to work with def zServerLogic[R](logic: I => Task[Either[E, O]])?
Maybe we could provide def zServerLogicFallible[R](logic: I => RIO[Either[E, O]]), would that work?