sup has modules for http4s, http4s-client and circe:

libraryDependencies ++= Seq(
  "com.kubukoz" %% "sup-http4s" % "0.8.0",
  "com.kubukoz" %% "sup-http4s-client" % "0.8.0",
  "com.kubukoz" %% "sup-circe" % "0.8.0"
)

Imports:

import sup._
import sup.modules.http4s._, sup.modules.http4sclient._, sup.modules.circe._

What’s included

statusCodeHealthCheck, healthCheckRoutes, Encoder/Decoder

In the http4s module, you get a router for (almost) free. You just need some instances, a healthcheck and an EntityEncoder[F, HealthResult[H]].

The circe module provides circe Encoder/Decoder instances for all the important bits, so you can use them together with http4s-circe and bundle the whole thing up:

import io.circe._, org.http4s.circe.CirceEntityCodec._, org.http4s._, org.http4s.implicits._, org.http4s.client._
import cats.effect._, cats._, cats.data._, sup.data._

implicit val client: Client[IO] = Client.fromHttpApp(HttpApp.notFound[IO])
// client: Client[IO] = org.http4s.client.Client$$anon$1@571a1ead
 
val healthcheck: HealthCheck[IO, Id] = statusCodeHealthCheck(Request[IO]())
// healthcheck: HealthCheck[IO, Id] = sup.HealthCheck$$anon$1@5ebecf93

val routes = healthCheckRoutes(healthcheck)
// routes: HttpRoutes[IO] = Kleisli(
//   org.http4s.HttpRoutes$$$Lambda$9899/0x0000000102cf9840@3dfe8b40
// )

//also works with reports!

val report = HealthReporter.fromChecks(
  healthcheck.through(mods.tagWith("foo")),
  HealthCheck.const[IO, Id](Health.Healthy).through(mods.tagWith("bar"))
)
// report: HealthReporter[IO, NonEmptyList, Tagged[String, H]] = sup.HealthCheck$$anon$1@3707af2c

val reportRoutes = healthCheckRoutes(report)
// reportRoutes: HttpRoutes[IO] = Kleisli(
//   org.http4s.HttpRoutes$$$Lambda$9899/0x0000000102cf9840@22640cc7
// )

val responseBody = reportRoutes.orNotFound.run(Request(uri = Uri.uri("/health-check"))).flatMap(_.bodyAsText.compile.string)
// responseBody: IO[String] = Bind(
//   Map(
//     Suspend(org.http4s.HttpRoutes$$$Lambda$9903/0x0000000102cfe440@5e8a2ba6),
//     cats.data.OptionT$$Lambda$9905/0x0000000102cfc840@547e8194,
//     0
//   ),
//   <function1>
// )
println(responseBody.unsafeRunSync())
// {"health":"Sick","checks":[{"tag":"foo","health":"Sick"},{"tag":"bar","health":"Healthy"}]}

remoteHealthCheck

There’s a way to build a healthcheck out of a request to a remote one:

val remoteCheck = remoteHealthCheck[IO, Id](Request())
// remoteCheck: HealthCheck[IO, Id] = sup.HealthCheck$$anon$1@56febde8