From 41f7b2381f729f9a224097818ef3358a37e11c32 Mon Sep 17 00:00:00 2001 From: johannes karoff Date: Thu, 13 Jun 2024 02:18:26 +0200 Subject: [PATCH] update readme --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 1a56ab4f..464deeac 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,36 @@ new Api { } ``` +## Integrations + +### http4s + +Use with: +``` +libraryDependencies += "com.github.cornerman" %%% "sloth-http4s-server" % "0.7.1" +libraryDependencies += "com.github.cornerman" %%% "sloth-http4s-client" % "0.7.1" +``` + +On the server: +```scala +import sloth.Router +import sloth.ext.http4s.server.HttpRpcRoutes + +val router = Router[String, IO] +val rpcRoutes: HttpRoutes[IO] = HttpRpcRoutes[String, IO](router) +// see HttpRpcRoutes.eventStream[IO] for streaming server sent events +``` + +In the client: +```scala +import sloth.Client +import sloth.ext.http4s.client.HttpRpcTransport + +val client = Client[String, fs2.Stream[IO, *]](HttpRpcTransport.eventStream[IO]) +val api: MyApi[fs2.Stream[IO, *]] = client.wire[MyApi[fs2.Stream[IO, *]]] +// see HttpRpcTransport.eventStream[IO] for streaming server sent events +``` + ## Experimental: Checksum for Apis Currently scala-2 only.