1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

add websocket streaming to api rpc handler (#1326)

This commit is contained in:
Asim Aslam
2020-03-10 15:21:43 +00:00
committed by GitHub
parent 241614ff68
commit ed83c27f0e
3 changed files with 168 additions and 4 deletions

View File

@ -104,9 +104,20 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// micro client
c := h.opts.Service.Client()
// create context
cx := ctx.FromRequest(r)
// if stream we currently only support json
if isStream(r, service) {
serveWebsocket(cx, w, r, service, c)
return
}
// create strategy
so := selector.WithStrategy(strategy(service.Services))
// walk the standard call path
// get payload
br, err := requestPayload(r)
if err != nil {
@ -114,9 +125,6 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
// create context
cx := ctx.FromRequest(r)
var rsp []byte
switch {