Skip to content

Commit

Permalink
Code golf routes builder
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Apr 3, 2024
1 parent e43aa5b commit 1592e64
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions modules/backend/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ object Routes:
private val federations: Resource[IO, HttpRoutes[IO]] =
SimpleRestJsonBuilder.routes(federationServiceImpl).resource

private val docs: HttpRoutes[IO] =
smithy4s.http4s.swagger.docs[IO](PlayerService, FederationService, HealthService)
private val docs: Resource[IO, HttpRoutes[IO]] =
smithy4s.http4s.swagger.docs[IO](PlayerService, FederationService, HealthService).pure[Resource[IO, *]]

val serviceRoutes: Resource[IO, HttpRoutes[IO]] = (players, federations, health).mapN(_ <+> _ <+> _)

val all: Resource[IO, HttpRoutes[IO]] = serviceRoutes.map(_ <+> docs)
val all: Resource[IO, HttpRoutes[IO]] = List(players, federations, health).fold(docs)(_ <+> _)

object Main extends IOApp.Simple:
val run = Routes.all
Expand Down

0 comments on commit 1592e64

Please sign in to comment.