Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to use in concrete IO? #115

Open
adamjuhasz opened this issue Feb 13, 2024 · 0 comments
Open

Possible to use in concrete IO? #115

adamjuhasz opened this issue Feb 13, 2024 · 0 comments

Comments

@adamjuhasz
Copy link

We have some legacy http4s apps that are in concrete IO, is there any easy way to lift IO into TracedIO?

Thanks!

example

case class ApplicationRoutes(services: ApplicationServices) {
    private val authMiddleware = AuthMiddleware(services.bar)
  
  private val clientClientRoutes: HttpRoutes[IO] = ClientClientRoutes(services.baz).routes(authMiddleware)

  private val adminClientRoutes: HttpRoutes[IO] = AdminClientRoutes(services.foo).routes(authMiddleware)

  private val newRoutes: HttpRoutes[IO] = adminClientRoutes <+> clientClientRoutes

  val httpApp: HttpApp[IO] = appRoutes.orNotFound
}

object AppMain extends IOApp {
  override def run(): IO[ExitCode] = {
    Resources.make(config).use {
      val httpApp = ApplicationRoutes(ApplicationServices()).appRoutes

      // Would be great to wrap `httpApp` here with `TraceMiddleware`

      BlazeServerBuilder[IO]
        .bindHttp(httpPort, httpHost)
        .withHttpApp(httpApp)
        .withServiceErrorHandler(errorHandler)
        .resource
        .run
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant