You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
437 B

  1. package jsonrpc
  2. import (
  3. "context"
  4. "github.com/intel-go/fastjson"
  5. )
  6. type requestIDKey struct{}
  7. // RequestID takes request id from context.
  8. func RequestID(c context.Context) *fastjson.RawMessage {
  9. return c.Value(requestIDKey{}).(*fastjson.RawMessage)
  10. }
  11. // WithRequestID adds request id to context.
  12. func WithRequestID(c context.Context, id *fastjson.RawMessage) context.Context {
  13. return context.WithValue(c, requestIDKey{}, id)
  14. }