mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
plugin/template: support metadata (#2958)
* Enable use of metadata in templates * Update README * Don't stash away ctx, instead use a new func
This commit is contained in:
@@ -82,6 +82,16 @@ func Labels(ctx context.Context) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValueFuncs returns the map[string]Func from the context, or nil if it does not exist.
|
||||
func ValueFuncs(ctx context.Context) map[string]Func {
|
||||
if metadata := ctx.Value(key{}); metadata != nil {
|
||||
if m, ok := metadata.(md); ok {
|
||||
return m
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValueFunc returns the value function of label. If none can be found nil is returned. Calling the
|
||||
// function returns the value of the label.
|
||||
func ValueFunc(ctx context.Context, label string) Func {
|
||||
|
||||
Reference in New Issue
Block a user