http4s / http4s-finagle

Http4s on Finagle Server or Client

GitHub

Http4s Finagle

Build codecov
Cats Friendly Badge

if your http4s version is 0.21.x simply set http4s-finagle to 0.21+

libraryDependencies += "org.http4s" %% "http4s-finagle" % "0.21+"

if in any circumstance you need fix the finagle version(most cases not, finagle api is quite stable)

libraryDependencies += "org.http4s" %% "http4s-finagle" % "0.21.4-20.4.1-0"
                                                           ^      ^      ^
                                                      http4s   fingale   patch

Server

To run Http4s app on Finagle Http server, simply just use Finagle.mkService to adapt Http4s HttpApp[F] to Fingale Service[Request, Response].

import org.http4s.finagle._

val http4sService: HttpApp[IO] = ???

val server = Http.server.serve(":8080", Finagle.mkService(http4sService))
Await.ready(server)

Client

import org.http4s.finagle._
import com.twitter.finagle.Http

val host = "blog.oyanglul.us"
Finagle.mkClient[IO](Http.client.withTls(host).newService(s"$host:443")).use {
  client: Client[IO] =>
  ...
}

Please refer to the Test which is fully functional server and client.