// Retruns the Context associated with the http.Request.
507311
func Get(r *http.Request) *Context {

	// get the context bound to the http.Request
	if v, ok := r.Body.(*wrapper); ok {
		return v.context
	}

	// create a new context
	c := Context{ }
	c.Params = make(Params)
	c.Values = make(Values)
	c.req = r

	// wrap the request and bind the context
	wrapper := wrap(r)
	wrapper.context = &c
	return &c
}
414892
func deleteRequestContext(r *http.Request) {
	contextMutex.Lock()
	delete(requestContextMap, r)
	contextMutex.Unlock()
}
259984
func (c *UpstreamDeleteCall) Context(ctx context.Context) *UpstreamDeleteCall {
	c.ctx_ = ctx
	return c
}
971029
func (r *Request) Context(ctx context.Context) *Request {
	r.ctx = ctx
	return r
}
193296
func (c *RetryCall) Context(ctx context.Context) *RetryCall {
	c.ctx_ = ctx
	return c
}
1207247
func (c *Config) getContext() context.Context {
	client := &http.Client{
		Transport: util.NewRoundTripper(log.Get(), c.Client.ExtraHeaders),
	}

	return context.WithValue(context.Background(), oauth2.HTTPClient, client)
}
611772
func (c *BotGetCall) Context(ctx context.Context) *BotGetCall {
	c.ctx_ = ctx
	return c
}
283279
func Context(r *http.Request) *WC {
	wc, _ := r.Context().Value(wgoCtxKey).(*WC)
	return wc
}
287819
func Context(ctx context.Context) RequestOpt {
	return func(r *http.Request) {
		r2 := r.WithContext(ctx)
		*r = *r2
	}
}
474517
func (c *PutBatchCall) Context(ctx context.Context) *PutBatchCall {
	c.ctx_ = ctx
	return c
}
932169
func (c *GetCall) Context(ctx context.Context) *GetCall {
	c.ctx_ = ctx
	return c
}
611753
func (c *StoreInlineCall) Context(ctx context.Context) *StoreInlineCall {
	c.ctx_ = ctx
	return c
}
156090
func (c *PutCall) Context(ctx context.Context) *PutCall {
	c.ctx_ = ctx
	return c
}
1345331
func GetContextFromRequest(req *protos.Request, serverID string) (context.Context, error) {
	ctx, err := pcontext.Decode(req.GetMetadata())
	if err != nil {
		return nil, err
	}
	if ctx == nil {
		return nil, constants.ErrNoContextFound
	}
	tags := opentracing.Tags{
		"local.id":     serverID,
		"span.kind":    "server",
		"peer.id":      pcontext.GetFromPropagateCtx(ctx, constants.PeerIDKey),
		"peer.service": pcontext.GetFromPropagateCtx(ctx, constants.PeerServiceKey),
		"request.id":   pcontext.GetFromPropagateCtx(ctx, constants.RequestIDKey),
	}
	parent, err := tracing.ExtractSpan(ctx)
	if err != nil {
		logger.Log.Warnf("failed to retrieve parent span: %s", err.Error())
	}
	ctx = tracing.StartSpan(ctx, req.GetMsg().GetRoute(), tags, parent)
	ctx = CtxWithDefaultLogger(ctx, req.GetMsg().GetRoute(), "")
	return ctx, nil
}
164427
func (c *AppListCall) Context(ctx context.Context) *AppListCall {
	c.ctx_ = ctx
	return c
}
1234080
func addtoContext(r *http.Request, key string, value interface{}) *http.Request {
	ctx := r.Context()
	return r.WithContext(context.WithValue(ctx, key, value))
}
790792
func GetContext(w http.ResponseWriter) (map[interface{}]interface{}, bool) {
	ctxw, ok := GetResponseWriter(w, func(tst http.ResponseWriter) bool {
		_, ok := tst.(*contextResponseWriter)
		return ok
	})
	if ok {
		return ctxw.(*contextResponseWriter).m, true
	}
	return nil, false
}