mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
plugin/rewrite: streamline the ResponseRule handling. (#4473)
* plugin/rewrite: streamline the ResponseRule handling. The functionality of a response rule is now completely encapsulated behind a `ResponseRule` interface. This significantly simplifies the complete processing flow, it enables more flexible response handling and it is possible to eliminate lots of state flags, ifs and switches. Based on the new flexibility the pull request also enables to support a response name rewrite for all name rewrite types. To be compatible, an explicit `answer auto` option is added to support a best effort response rewrite (name and value). Additionally now all name rewrite rules support additional name and value reponse rewrite options. Using this feature it is also possible now to rewrite a complete sub domain hierarchy to a single domain name combined with a correct rewrite (#2389). Signed-off-by: Uwe Krueger <uwe.krueger@sap.com> * revert policy Signed-off-by: Uwe Krueger <uwe.krueger@sap.com> Co-authored-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -44,12 +44,12 @@ func TestParse(t *testing.T) {
|
||||
`rewrite stop {
|
||||
name regex foo bar
|
||||
answer name bar foo
|
||||
name baz qux
|
||||
name baz
|
||||
}`)
|
||||
_, err = rewriteParse(c)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error but got success for invalid response rewrite")
|
||||
} else if !strings.Contains(err.Error(), "must consist only of") {
|
||||
} else if !strings.Contains(err.Error(), "2 arguments required") {
|
||||
t.Errorf("Got wrong error for invalid response rewrite: %v", err.Error())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user