aboutsummaryrefslogtreecommitdiff
path: root/plugin/header/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/header/handler.go')
-rw-r--r--plugin/header/handler.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugin/header/handler.go b/plugin/header/handler.go
new file mode 100644
index 000000000..a002c4fb1
--- /dev/null
+++ b/plugin/header/handler.go
@@ -0,0 +1,24 @@
+package header
+
+import (
+ "context"
+
+ "github.com/coredns/coredns/plugin"
+
+ "github.com/miekg/dns"
+)
+
+// Header modifies dns.MsgHdr in the responses
+type Header struct {
+ Rules []Rule
+ Next plugin.Handler
+}
+
+// ServeDNS implements the plugin.Handler interface.
+func (h Header) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
+ wr := ResponseHeaderWriter{ResponseWriter: w, Rules: h.Rules}
+ return plugin.NextOrFailure(h.Name(), h.Next, ctx, &wr, r)
+}
+
+// Name implements the plugin.Handler interface.
+func (h Header) Name() string { return "header" }