Skip to content

IndiscriminateCoding/jetty4s

Repository files navigation

jetty4s - Jetty client and server backends for http4s

Usage

Add this library to your build.sbt:

libraryDependencies ++= List(
  "com.github.IndiscriminateCoding" %% "jetty4s-client" % jetty4sVersion,
  "com.github.IndiscriminateCoding" %% "jetty4s-server" % jetty4sVersion
)

Now you can use jetty4s.client.JettyClientBuilder to create a Client[F]:

val clientResource: Resource[IO, Client[IO]] = JettyClientBuilder[IO]
  .withRequestTimeout(FiniteDuration(5, TimeUnit.SECONDS))
  .withExecutor(new QueuedThreadPool(16))
  .resource

And jetty4s.server.JettyServerBuilder to run your HttpApp[F]:

val serverResource: Resource[IO, List[Server[IO]]] = JettyServerBuilder[IO]
  .withHttpApp(app)
  .resource