RegisterHandlerDirective is like RegisterDirective, but for directives which specifically output only an HTTP handler. Directives registered with this function will always have an optional matcher token as the first argument.
(dir string, setupFunc UnmarshalHandlerFunc)
| 118 | // Directives registered with this function will always have |
| 119 | // an optional matcher token as the first argument. |
| 120 | func RegisterHandlerDirective(dir string, setupFunc UnmarshalHandlerFunc) { |
| 121 | RegisterDirective(dir, func(h Helper) ([]ConfigValue, error) { |
| 122 | if !h.Next() { |
| 123 | return nil, h.ArgErr() |
| 124 | } |
| 125 | |
| 126 | matcherSet, err := h.ExtractMatcherSet() |
| 127 | if err != nil { |
| 128 | return nil, err |
| 129 | } |
| 130 | |
| 131 | val, err := setupFunc(h) |
| 132 | if err != nil { |
| 133 | return nil, err |
| 134 | } |
| 135 | |
| 136 | return h.NewRoute(matcherSet, val), nil |
| 137 | }) |
| 138 | } |
| 139 | |
| 140 | // RegisterDirectiveOrder registers the default order for a |
| 141 | // directive from a plugin. |
no test coverage detected