danielgtaylor / huma

Huma REST/HTTP API Framework for Golang with OpenAPI 3.1
https://huma.rocks/
MIT License
2.01k stars 146 forks source link

how to integrate websockets, should the need arise? #570

Open VuongUranus opened 1 month ago

VuongUranus commented 1 month ago

how to integrate websockets, should the need arise?

danielgtaylor commented 1 week ago

@VuongUranus you have full access to the underlying router and can use any websocket library compatible with your router choice (or the router itself it it supports websockets directly). If you want some of the Huma goodies like validation of request inputs then you can take a look at the SSE package as it implements SSE support on top of a streaming response within Huma: https://github.com/danielgtaylor/huma/blob/main/sse/sse.go and https://huma.rocks/features/server-sent-events-sse/.

lei-lei-shanda commented 1 week ago

It would be great if web socket + AsyncAPI 2.x is supported out of box though. For the time being, the above trick would do.

Async API: https://www.asyncapi.com/en