swift-server/async-http-client

Support for SSE (EventSource)

koraykoska opened this issue · 3 comments

I didn't find anything so thought I should ask. Is there any support for EventSource (client side of course)? If not, would it be possible to build something around the existing library without having to support it upstream?

Hi @koraykoska,

you can build both a client and a server side of SSE using Swift OpenAPI Generator, which can use AHC under the hood.

Steps:

  1. Clone this example project: https://github.com/apple/swift-openapi-generator/tree/main/Examples/event-streams-client-example
  2. Switch the transport from the URLSession transport to the AsyncHTTPClient transport: https://github.com/swift-server/swift-openapi-async-http-client
  3. Update the OpenAPI doc to match the service you're connecting to

Thank you @czechboy0 ! Just what I was looking for.