Skip to content

Commit

Permalink
embed: support websocket for bi-directional streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Iwasaki Yudai committed Oct 5, 2017
1 parent 867e3da commit 37eabd7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion embed/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

gw "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/soheilhy/cmux"
"github.com/tmc/grpc-websocket-proxy/wsproxy"
"golang.org/x/net/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -214,7 +215,19 @@ func (sctx *serveCtx) createMux(gwmux *gw.ServeMux, handler http.Handler) *http.
httpmux.Handle(path, h)
}

httpmux.Handle("/v3alpha/", gwmux)
httpmux.Handle(
"/v3alpha/",
wsproxy.WebsocketProxy(
gwmux,
wsproxy.WithRequestMutator(
// Default to the POST method for streams
func(incoming *http.Request, outgoing *http.Request) *http.Request {
outgoing.Method = "POST"
return outgoing
},
),
),
)
if handler != nil {
httpmux.Handle("/", handler)
}
Expand Down

0 comments on commit 37eabd7

Please sign in to comment.