endpoints4s
The snunit-endpoints4s artifact offers a synchronous endpoints4s
server interpreter. Mix snunit.endpoints4s.Endpoints with your endpoint definitions and
pass toHandler(endpoint.implementedBy(...)) to SyncServerBuilder.setRequestHandler:
//> using dep com.github.lolgab::snunit-endpoints4s::0.13.0
import endpoints4s.algebra
trait HelloWorldEndpoints extends algebra.Endpoints {
val helloWorld = endpoint(get(path / "hello" /? qs[String]("name")), ok(textResponse))
}
object Endpoints4sHelloWorld extends snunit.endpoints4s.Endpoints with HelloWorldEndpoints {
def main(args: Array[String]): Unit =
snunit.SyncServerBuilder
.setRequestHandler(toHandler(helloWorld.implementedBy(name => s"Hello $name!")))
.build()
.listen()
}
You can find an example in tests.