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@633e1182
 
val healthcheck: HealthCheck[IO, Id] = statusCodeHealthCheck(Request[IO]())
// healthcheck: HealthCheck[IO, Id] = sup.HealthCheck$$anon$1@625f899b

val routes = healthCheckRoutes(healthcheck)
// routes: HttpRoutes[IO] = Kleisli(
//   org.http4s.HttpRoutes$$$Lambda$10305/0x0000000102fb7040@3f8e325b
// )

//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@7ad69cf7

val reportRoutes = healthCheckRoutes(report)
// reportRoutes: HttpRoutes[IO] = Kleisli(
//   org.http4s.HttpRoutes$$$Lambda$10305/0x0000000102fb7040@77c0381
// )

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$10309/0x0000000102fb4040@73b92163),
//     cats.data.OptionT$$Lambda$10311/0x0000000102fb3040@3d463ac7,
//     StackTrace(
//       List(
//         cats.effect.internals.IOTracing$.buildFrame(IOTracing.scala:48),
//         cats.effect.internals.IOTracing$.buildCachedFrame(IOTracing.scala:39),
//         cats.effect.internals.IOTracing$.cached(IOTracing.scala:34),
//         cats.effect.IO.map(IO.scala:106),
//         cats.effect.IOLowPriorityInstances$IOEffect.map(IO.scala:870),
//         cats.effect.IOLowPriorityInstances$IOEffect.map(IO.scala:863),
//         cats.data.OptionT.getOrElse(OptionT.scala:99),
//         org.http4s.syntax.KleisliResponseOps.$anonfun$orNotFound$1(KleisliSyntax.scala:38),
//         repl.Session$App.<init>(http4s-circe.md:47),
//         repl.Session$.app(http4s-circe.md:3),
//         mdoc.internal.document.DocumentBuilder$$doc$.$anonfun$build$2(DocumentBuilder.scala:82),
//         scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23),
//         scala.util.DynamicVariable.withValue(DynamicVariable.scala:62),
//         scala.Console$.withErr(Console.scala:196),
//         mdoc.internal.document.DocumentBuilder$$doc$.$anonfun$build$1(DocumentBuilder.scala:82),
//         scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23),
//         scala.util.DynamicVariable.withValue(DynamicVariable.scala:62),
//         scala.Console$.withOut(Console.scala:167),
//         mdoc.internal.document.DocumentBuilder$$doc$.build(DocumentBuilder.scala:81),
//         mdoc.internal.markdown.MarkdownCompiler$.buildDocument(MarkdownCompiler.scala:53),
//         mdoc.internal.markdown.Processor.processScalaInputs(Processor.scala:133),
//         mdoc.internal.markdown.Processor.processDocument(Processor.scala:48),
//         mdoc.internal.markdown.Markdown$.toMarkdown(Markdown.scala:118),
//         mdoc.internal.cli.MainOps.handleMarkdown(MainOps.scala:62),
//         mdoc.internal.cli.MainOps.handleFile(MainOps.scala:90),
//         mdoc.internal.cli.MainOps.$anonfun$generateCompleteSite$1(MainOps.scala:130),
//         scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126),
//         scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122),
//         scala.collection.immutable.List.foldLeft(List.scala:89),
//         mdoc.internal.cli.MainOps.generateCompleteSite(MainOps.scala:128),
//         mdoc.internal.cli.MainOps.run(MainOps.scala:149),
//         mdoc.internal.cli.MainOps$.process(MainOps.scala:233),
//         mdoc.Main$.process(Main.scala:26),
//         mdoc.Main$.process(Main.scala:21),
// ...
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@5a4146e5