mirror of
https://github.com/coredns/coredns.git
synced 2025-09-25 07:31:16 +02:00
plugin/metadata: tweak the docs a little (#2685)
Add a simpler example that returns a static string the for metadata. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
d69f97be5c
commit
d652f72fa7
@ -6,7 +6,14 @@
|
|||||||
//
|
//
|
||||||
// Basic example:
|
// Basic example:
|
||||||
//
|
//
|
||||||
// Implement the Provider interface for a plugin:
|
// Implement the Provider interface for a plugin p:
|
||||||
|
//
|
||||||
|
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
||||||
|
// metadata.SetValueFunc(ctx, "test/something", func() string { return "myvalue" })
|
||||||
|
// return ctx
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Basic example with caching:
|
||||||
//
|
//
|
||||||
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
||||||
// cached := ""
|
// cached := ""
|
||||||
@ -21,7 +28,7 @@
|
|||||||
// return ctx
|
// return ctx
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Check the metadata from another plugin:
|
// If you need access to this metadata from another plugin:
|
||||||
//
|
//
|
||||||
// // ...
|
// // ...
|
||||||
// valueFunc := metadata.ValueFunc(ctx, "test/something")
|
// valueFunc := metadata.ValueFunc(ctx, "test/something")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user