MCPcopy
hub / github.com/caddyserver/caddy / RegisterHandlerDirective

Function RegisterHandlerDirective

caddyconfig/httpcaddyfile/directives.go:120–138  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

118// Directives registered with this function will always have
119// an optional matcher token as the first argument.
120func 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.

Callers 14

initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92

Calls 5

RegisterDirectiveFunction · 0.85
ArgErrMethod · 0.80
ExtractMatcherSetMethod · 0.80
NewRouteMethod · 0.80
NextMethod · 0.65

Tested by

no test coverage detected