aboutsummaryrefslogtreecommitdiff
path: root/plugin/header/handler.go
blob: a002c4fb13fb9ef149f69d9275f19ffeb5ae2e6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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" }