| 372 | } |
| 373 | |
| 374 | func (n *node) FindRoute(rctx *Context, method methodTyp, path string) (*node, endpoints, http.Handler) { |
| 375 | // Reset the context routing pattern and params |
| 376 | rctx.routePattern = "" |
| 377 | rctx.routeParams.Keys = rctx.routeParams.Keys[:0] |
| 378 | rctx.routeParams.Values = rctx.routeParams.Values[:0] |
| 379 | |
| 380 | // Find the routing handlers for the path |
| 381 | rn := n.findRoute(rctx, method, path) |
| 382 | if rn == nil { |
| 383 | return nil, nil, nil |
| 384 | } |
| 385 | |
| 386 | // Record the routing params in the request lifecycle |
| 387 | rctx.URLParams.Keys = append(rctx.URLParams.Keys, rctx.routeParams.Keys...) |
| 388 | rctx.URLParams.Values = append(rctx.URLParams.Values, rctx.routeParams.Values...) |
| 389 | |
| 390 | // Record the routing pattern in the request lifecycle |
| 391 | if rn.endpoints[method].pattern != "" { |
| 392 | rctx.routePattern = rn.endpoints[method].pattern |
| 393 | rctx.RoutePatterns = append(rctx.RoutePatterns, rctx.routePattern) |
| 394 | } |
| 395 | |
| 396 | return rn, rn.endpoints, rn.endpoints[method].handler |
| 397 | } |
| 398 | |
| 399 | // Recursive edge traversal by checking all nodeTyp groups along the way. |
| 400 | // It's like searching through a multi-dimensional radix trie. |