tapir-loom

tapir + loom integration.

Requires Java 19, and the --enable-preview java option to be provided.

There are currently two server interpreters available:

  • one using Netty, running the server logic on virtual threads
  • and one using an alpha release of Helidon Nima 4

Try running SleepDemo with some load: wrk -c 100 http://localhost:8080/hello.

To use, add one of the following dependencies:

"com.softwaremill.sttp.tapir" %% "tapir-netty-server-id" % "0.1.1"
// or
"com.softwaremill.sttp.tapir" %% "tapir-nima-server" % "0.1.1"

Then, use NimaServerInterpreter or the NettyIdServer as other netty server variants. For example:

import sttp.tapir._

object SleepDemo extends App {
  val e = endpoint.get.in("hello").out(stringBody).serverLogicSuccess[Id] { _ =>
    Thread.sleep(1000)
    "Hello, world!"
  }
  NettyIdServer().addEndpoint(e).start()
}