mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-11 08:43:34 +08:00
httpserver: Added function to register directive at runtime (dev only)
This function should not be used outside of development. It destroys the absolute ordering and guarantees of correctness. Multiple uses of it may work fine, but maybe not if they overlap, causing non-deterministic builds which is bad. However, this can be convenient when developing a plugin by calling it from an init() function, since you don't have to modify the Caddy source code just to try your plugin.
This commit is contained in:
@ -137,3 +137,23 @@ func TestInspectServerBlocksWithCustomDefaultPort(t *testing.T) {
|
||||
t.Errorf("Expected the port on the address to be set, but got: %#v", addr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDirectivesList(t *testing.T) {
|
||||
for i, dir1 := range directives {
|
||||
if dir1 == "" {
|
||||
t.Errorf("directives[%d]: empty directive name", i)
|
||||
continue
|
||||
}
|
||||
if got, want := dir1, strings.ToLower(dir1); got != want {
|
||||
t.Errorf("directives[%d]: %s should be lower-cased", i, dir1)
|
||||
continue
|
||||
}
|
||||
for j := i + 1; j < len(directives); j++ {
|
||||
dir2 := directives[j]
|
||||
if dir1 == dir2 {
|
||||
t.Errorf("directives[%d] (%s) is a duplicate of directives[%d] (%s)",
|
||||
j, dir2, i, dir1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user