mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
@@ -12,7 +12,7 @@ type ClassRule struct {
|
||||
fromClass, toClass uint16
|
||||
}
|
||||
|
||||
// Initializer
|
||||
// New initializes rule.
|
||||
func (rule ClassRule) New(args ...string) Rule {
|
||||
from, to := args[0], strings.Join(args[1:], " ")
|
||||
return &ClassRule{dns.StringToClass[from], dns.StringToClass[to]}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Package rewrite is middleware for rewriting requests internally to something different.
|
||||
package rewrite
|
||||
|
||||
/*
|
||||
Additional FIELD keywords may be implemented to support more rewrite use-cases.
|
||||
New Rule types must be added to the Fields map.
|
||||
The type must implement `New` and `Rewrite` functions.
|
||||
*/
|
||||
// Fields defines additional FIELD keywords may be implemented to support more rewrite use-cases.
|
||||
// New Rule types must be added to the Fields map.
|
||||
// The type must implement `New` and `Rewrite` functions.
|
||||
var Fields = map[string]Rule{
|
||||
"name": NameRule{},
|
||||
"type": TypeRule{},
|
||||
|
||||
@@ -13,7 +13,7 @@ type NameRule struct {
|
||||
From, To string
|
||||
}
|
||||
|
||||
// Initializer
|
||||
// New initializes a new rule.
|
||||
func (rule NameRule) New(args ...string) Rule {
|
||||
from, to := args[0], strings.Join(args[1:], " ")
|
||||
return &NameRule{middleware.Name(from).Normalize(), middleware.Name(to).Normalize()}
|
||||
|
||||
@@ -12,7 +12,7 @@ type TypeRule struct {
|
||||
fromType, toType uint16
|
||||
}
|
||||
|
||||
// Initializer
|
||||
// New initializes a rule.
|
||||
func (rule TypeRule) New(args ...string) Rule {
|
||||
from, to := args[0], strings.Join(args[1:], " ")
|
||||
return &TypeRule{dns.StringToType[from], dns.StringToType[to]}
|
||||
|
||||
Reference in New Issue
Block a user