NewRoute returns config values relevant to creating a new HTTP route.
(matcherSet caddy.ModuleMap, handler caddyhttp.MiddlewareHandler, )
| 278 | |
| 279 | // NewRoute returns config values relevant to creating a new HTTP route. |
| 280 | func (h Helper) NewRoute(matcherSet caddy.ModuleMap, |
| 281 | handler caddyhttp.MiddlewareHandler, |
| 282 | ) []ConfigValue { |
| 283 | mod, err := caddy.GetModule(caddy.GetModuleID(handler)) |
| 284 | if err != nil { |
| 285 | *h.warnings = append(*h.warnings, caddyconfig.Warning{ |
| 286 | File: h.File(), |
| 287 | Line: h.Line(), |
| 288 | Message: err.Error(), |
| 289 | }) |
| 290 | return nil |
| 291 | } |
| 292 | var matcherSetsRaw []caddy.ModuleMap |
| 293 | if matcherSet != nil { |
| 294 | matcherSetsRaw = append(matcherSetsRaw, matcherSet) |
| 295 | } |
| 296 | return []ConfigValue{ |
| 297 | { |
| 298 | Class: "route", |
| 299 | Value: caddyhttp.Route{ |
| 300 | MatcherSetsRaw: matcherSetsRaw, |
| 301 | HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(handler, "handler", mod.ID.Name(), h.warnings)}, |
| 302 | }, |
| 303 | }, |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | // GroupRoutes adds the routes (caddyhttp.Route type) in vals to the |
| 308 | // same group, if there is more than one route in vals. |
no test coverage detected