Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration package for http4s #242

Merged
merged 2 commits into from
Jun 13, 2024
Merged

integration package for http4s #242

merged 2 commits into from
Jun 13, 2024

Conversation

cornerman
Copy link
Owner

@cornerman cornerman commented Jun 12, 2024

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:

import sloth.Router
import sloth.ext.http4s.server.HttpRpcRoutes

// for usual rpc
val router = Router[String, IO]
val rpcRoutes: HttpRoutes[IO] = HttpRpcRoutes[String, IO](router)

// for server sent event over rpc
val router = Router[String, fs2.Stream[IO, *]]
val rpcRoutes: HttpRoutes[IO] = HttpRpcRoutes.eventStream[IO](router)

In the client:

import sloth.Client
import sloth.ext.http4s.client.HttpRpcTransport

// for usual rpc
val client = Client[String, IO](HttpRpcTransport[String, IO])
val api: MyApi[IO] = client.wire[MyApi[IO]]

// for server sent events over rpc
val client = Client[String, fs2.Stream[IO, *]](HttpRpcTransport.eventStream[IO])
val api: MyApi[fs2.Stream[IO, *]] = client.wire[MyApi[fs2.Stream[IO, *]]]

See #21

@cornerman cornerman marked this pull request as ready for review June 13, 2024 17:29
@cornerman cornerman merged commit 69229be into master Jun 13, 2024
4 checks passed
@cornerman cornerman deleted the http4s branch June 13, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant