 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Variables
- func ConfigFromContext(ctx context.Context) (*configx.Provider, error)
- func IsRootContext(ctx context.Context) bool
- func MustConfigFromContext(ctx context.Context) *configx.Provider
- func SetNIDContext(ctx context.Context, nid uuid.UUID) context.Context
- func WithConfig(ctx context.Context, p *configx.Provider) context.Context
- type ContextKey
- type Contextualizer
- type Default
- type Provider
- type Static
- type TestContextualizer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
      View Source
      
  var ErrNoConfigInContext = errors.New("configuration provider not found in context")
    ErrNoConfigInContext is returned when no config is found in the context.
      View Source
      
  
var RootContext = context.WithValue(context.Background(), ValidContextKey, true)
    Functions ¶
func ConfigFromContext ¶
ConfigFromContext returns the configuration provider from the context or an error if no configuration provider is found in the context.
Example ¶
ctx := context.Background()
config, err := configx.New(ctx, []byte(`{"type":"object","properties":{"foo":{"type":"string"}}}`), configx.WithValue("foo", "bar"))
if err != nil {
	panic(err)
}
ctx = WithConfig(ctx, config)
fmt.Printf("foo = %s", MustConfigFromContext(ctx).String("foo"))
Output: foo = bar
func IsRootContext ¶
func MustConfigFromContext ¶
MustConfigFromContext returns the configuration provider from the context or panics if no configuration provider is found in the context.
func SetNIDContext ¶ added in v0.0.387
SetNIDContext sets the nid for the given context.
Types ¶
type Contextualizer ¶ added in v0.0.387
type Provider ¶ added in v0.0.387
type Provider interface {
	Contextualizer() Contextualizer
}
    type TestContextualizer ¶ added in v0.0.387
type TestContextualizer struct{}
    TestContextualizer is a mock implementation of the Contextualizer interface.
 Click to show internal directories. 
   Click to hide internal directories.