Skip to content

Commit

Permalink
kyo-tapir wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Feb 26, 2024
1 parent 6612ae6 commit 40d781d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions kyo-tapir/src/main/scala/kyo/routes.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kyo

import izumi.reflect.*
import kyo.internal.KyoSttpMonad
import kyo.internal.KyoSttpMonad.*
import kyo.server.*
Expand All @@ -25,17 +26,20 @@ object Routes:
v.andThen(sums.get.map(server.addEndpoints(_)).map(_.start()))
}.map(_._1)

def add[T, U, E, S](e: Endpoint[Unit, T, Unit, U, Unit])(
f: T => U < Fibers
def add[S, A: Tag, I, E: Tag, O: Flat](e: Endpoint[A, I, E, O, Any])(
f: I => O < (Fibers & Envs[A] & Aborts[E])
): Unit < Routes =
sums.add(List(
e.serverLogic[KyoSttpMonad.M](f(_).map(Right(_))).asInstanceOf[Route[Any]]
e.serverSecurityLogic[A, KyoSttpMonad.M](a => Right(a)).serverLogic(a =>
i => Aborts[E].run(Envs[A].run(a)(f(i)))
)
)).unit
end add

def add[T, U, S](
e: PublicEndpoint[Unit, Unit, Unit, Any] => Endpoint[Unit, T, Unit, U, Any]
def add[S, A: Tag, I, E: Tag, O: Flat](
e: PublicEndpoint[Unit, Unit, Unit, Any] => Endpoint[A, I, E, O, Any]
)(
f: T => U < Fibers
f: I => O < (Fibers & Envs[A] & Aborts[E])
): Unit < Routes =
add(e(endpoint))(f)
end Routes
4 changes: 2 additions & 2 deletions kyo-tapir/src/main/scala/kyo/server/NettyKyoServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ object NettyKyoServer:
NettyKyoServer(
Vector.empty,
NettyKyoServerOptions.default(),
NettyConfig.defaultWithStreaming
NettyConfig.defaultNoStreaming
)
def apply(options: NettyKyoServerOptions): NettyKyoServer =
NettyKyoServer(Vector.empty, options, NettyConfig.defaultWithStreaming)
NettyKyoServer(Vector.empty, options, NettyConfig.defaultNoStreaming)
def apply(config: NettyConfig): NettyKyoServer =
NettyKyoServer(Vector.empty, NettyKyoServerOptions.default(), config)
def apply(
Expand Down

0 comments on commit 40d781d

Please sign in to comment.