NewContext creates a new context with peer information attached.
(ctx context.Context, p *Peer)
| 73 | |
| 74 | // NewContext creates a new context with peer information attached. |
| 75 | func NewContext(ctx context.Context, p *Peer) context.Context { |
| 76 | return context.WithValue(ctx, peerKey{}, p) |
| 77 | } |
| 78 | |
| 79 | // FromContext returns the peer information in ctx if it exists. |
| 80 | func FromContext(ctx context.Context) (p *Peer, ok bool) { |