示例#1
0
// matches a path in the path trie structure.
func matchPathTree(tree *pathmux.Tree, path string) (leafMatchers, map[string]string) {
	v, params := tree.Lookup(path)
	if v == nil {
		return nil, nil
	}

	// prepend slash in case of free form wildcards path segments (`/*name`),
	pm := v.(*pathMatcher)
	if pm.freeWildcardParam != "" {
		freeParam := params[pm.freeWildcardParam]
		freeParam = "/" + freeParam
		params[pm.freeWildcardParam] = freeParam
	}

	return pm.leaves, params
}