(method, path string, handlers HandlersChain)
| 362 | } |
| 363 | |
| 364 | func (engine *Engine) addRoute(method, path string, handlers HandlersChain) { |
| 365 | assert1(path[0] == '/', "path must begin with '/'") |
| 366 | assert1(method != "", "HTTP method can not be empty") |
| 367 | assert1(len(handlers) > 0, "there must be at least one handler") |
| 368 | |
| 369 | debugPrintRoute(method, path, handlers) |
| 370 | |
| 371 | root := engine.trees.get(method) |
| 372 | if root == nil { |
| 373 | root = new(node) |
| 374 | root.fullPath = "/" |
| 375 | engine.trees = append(engine.trees, methodTree{method: method, root: root}) |
| 376 | } |
| 377 | root.addRoute(path, handlers) |
| 378 | |
| 379 | if paramsCount := countParams(path); paramsCount > engine.maxParams { |
| 380 | engine.maxParams = paramsCount |
| 381 | } |
| 382 | |
| 383 | if sectionsCount := countSections(path); sectionsCount > engine.maxSections { |
| 384 | engine.maxSections = sectionsCount |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // Routes returns a slice of registered routes, including some useful information, such as: |
| 389 | // the http method, path, and the handler name. |
nothing calls this directly
no test coverage detected