mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Reviewed By: alexsn Differential Revision: D17119262 fbshipit-source-id: 046f095ca9432c920778db0edb2158dedb23c0a2
25 lines
701 B
Go
25 lines
701 B
Go
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
// Code generated (@generated) by entc, DO NOT EDIT.
|
|
|
|
package entv2
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type contextKey struct{}
|
|
|
|
// FromContext returns the Client stored in a context, or nil if there isn't one.
|
|
func FromContext(ctx context.Context) *Client {
|
|
c, _ := ctx.Value(contextKey{}).(*Client)
|
|
return c
|
|
}
|
|
|
|
// NewContext returns a new context with the given Client attached.
|
|
func NewContext(parent context.Context, c *Client) context.Context {
|
|
return context.WithValue(parent, contextKey{}, c)
|
|
}
|