Skip to content

Commit

Permalink
Add websocket handshake request header to metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbraemer committed Mar 3, 2022
1 parent 0207f68 commit 03d336f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ws/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,9 @@ func pingLoop(ctx context.Context, d time.Duration, ws *websocket.Conn) {
type httpRequestContextKey struct{}

func withRequest(ctx context.Context, r *http.Request) context.Context {
// Add websocket handshake request header to metadata
md, _ := metadata.FromIncomingContext(ctx)
ctx = metadata.NewIncomingContext(ctx, metadata.Join(md, metadata.MD(r.Header)))

return context.WithValue(ctx, httpRequestContextKey{}, r)
}

0 comments on commit 03d336f

Please sign in to comment.