plugin/header: Introduce header plugin (#4752)
* Add header plugin Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com> * fix import format * improve README.md * Add codeowners for header plugin
This commit is contained in:
parent
faa10f61af
commit
00128bda4e
8 changed files with 357 additions and 0 deletions
24
plugin/header/handler.go
Normal file
24
plugin/header/handler.go
Normal file
|
@ -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" }
|
Loading…
Add table
Add a link
Reference in a new issue