RegisterDirective registers a unique directive dir with an associated unmarshaling (setup) function. When directive dir is encountered in a Caddyfile, setupFunc will be called to unmarshal its tokens.
(dir string, setupFunc UnmarshalFunc)
| 107 | // is encountered in a Caddyfile, setupFunc will be called to |
| 108 | // unmarshal its tokens. |
| 109 | func RegisterDirective(dir string, setupFunc UnmarshalFunc) { |
| 110 | if _, ok := registeredDirectives[dir]; ok { |
| 111 | panic("directive " + dir + " already registered") |
| 112 | } |
| 113 | registeredDirectives[dir] = setupFunc |
| 114 | } |
| 115 | |
| 116 | // RegisterHandlerDirective is like RegisterDirective, but for |
| 117 | // directives which specifically output only an HTTP handler. |