//findParam walks up the matched node looking for parameters returns the last parameter
550284
func (p *Parameter) findParam(idx int) (string, error) {
	index := len(p.names) - 1
	urlPath := p.path
	pathLen := len(p.path)
	node := p.node

	for node != nil {
		if node.text[0] == ':' {
			ctn := lastIndexByte(urlPath, '/')
			if ctn == -1 {
				return "", fmt.Errorf("Parameter not found")
			}
			pathLen = ctn + 1
			if index == idx {
				return urlPath[pathLen:], nil
			}
			index--
		} else {
			pathLen -= len(node.text)
		}
		urlPath = urlPath[0:pathLen]
		node = node.parent
	}
	return "", fmt.Errorf("Parameter not found")
}
493288
func (ctx *Context) GETParam(argName string) []string {
	res := ctx.GETParams()
	if param, ok := res[argName]; ok {
		return param
	}
	return nil
}
1055259
func getParams(genericParams map[string]interface{}) (map[string]string, error) {
	params := map[string]string{}
	for key, value := range genericParams {
		strVal, isString := value.(string)
		if !isString {
			return nil, fmt.Errorf("expected string, saw %v for '%s'", value, key)
		}
		params[key] = strVal
	}
	return params, nil
}
1071565
func (f *Field) DeleteParam(key string) FieldInterface {
	delete(f.params, key)
	return f
}
1088276
func (s ScriptSort) Param(name string, value interface{}) ScriptSort {
	s.params[name] = value
	return s
}
943998
func Param(i interface{}) string {
	switch v := i.(type) {
	case string:
		return v
	case []string:
		return strings.Join(v, ",")
	case int:
		return strconv.Itoa(v)
	case []int:
		return slices.Ints(v).Join("", ",")
	case uint:
		return strconv.FormatUint(uint64(v), 10)
	case []uint:
		return slices.Uints(v).Join("", ",")
	case []byte:
		return string(v)
	}

	panic("Only support int, []int, uint, []uint, string, []string, []byte")
}
1025526
func PathParameter(name, description string) *Parameter {
	p := &Parameter{&ParameterData{Name: name, Description: description, Required: true, DataType: "string"}}
	p.bePath()
	return p
}
1264955
func (p *parser) isParam() bool {
	return (p.isSexpr() || p.isHelperName()) && !p.isHashSegment()
}
1124024
func (r *Router) GetParams(method, path string) (httprouter.Params, bool) {
	if h, p, _ := r.hrouter.Lookup(method, path); h != nil {
		return p, true
	}
	return nil, false
}
597017
func (this *Server) Param(p string, fn func(*Request, *Response, func())) {
	this.Router.AddParamFunc(p, fn)
}
265195
func (n *IcsNode) GetOneParam() (string, string) {
	if n.ParamsLen() == 0 {
		return "", ""
	}
	var key, val string
	for k, v := range n.Params {
		key, val = k, v
		break
	}
	return key, val
}
1343711
func (r *Request) Param(name, value string) *Request {
	r.Use(url.Param(name, value))
	return r
}
176194
func Param(c context.Context, key string) string {
	return C(c).Param(key)
}
829767
func Param(k string, v string) Filter {
	return func(r *http.Request) {
		q := r.URL.Query()
		q.Set(k, v)
		r.URL.RawQuery = q.Encode()
	}
}
893916
func (n *node) find(path string, po Params) (handler HandlersChain, p Params, handlerName string) {

	p = po

walk: // Outer loop for walking the tree
	for {
		if len(path) > len(n.path) {

			if path[:len(n.path)] == n.path {
				path = path[len(n.path):]

				// If this node does not have a wildcard (param or catchAll)
				// child,  we can just look up the next child node and continue
				// to walk down the tree
				if !n.wildChild {
					c := path[0]
					for i := 0; i < len(n.indices); i++ {
						if c == n.indices[i] {
							n = n.children[i]
							continue walk
						}
					}

					return
				}

				// handle wildcard child
				n = n.children[0]
				switch n.nType {
				case hasParams:

					// find param end (either '/' or path end)
					end := 0
					for end < len(path) && path[end] != slashByte {
						end++
					}

					// save param value
					i := len(p)
					p = p[:i+1] // expand slice within preallocated capacity
					p[i].Key = n.path[1:]
					p[i].Value = path[:end]

					// we need to go deeper!
					if end < len(path) {
						if len(n.children) > 0 {
							path = path[end:]
							n = n.children[0]
							continue walk
						}

						return
					}

					if n.handler != nil {
						handler = n.handler.chain
						handlerName = n.handler.handlerName
						return
					} else if len(n.children) == 1 {
						// No handle found. Check if a handle for this path
						n = n.children[0]
					}

					return

				case matchesAny:

					// save param value
					i := len(p)
					p = p[:i+1] // expand slice within preallocated capacity
					p[i].Key = WildcardParam
					p[i].Value = path[1:]

					handler = n.handler.chain
					handlerName = n.handler.handlerName
					return

					// can't happen, but left here in case I'm wrong
					// default:
					// 	panic("invalid node type")
				}
			}

		} else if path == n.path {

			// We should have reached the node containing the handle.
			// Check if this node has a handle registered.
			if n.handler != nil {
				if handler, handlerName = n.handler.chain, n.handler.handlerName; handler != nil {
					return
				}
			}
		}

		// Nothing found
		return
	}
}
628214
func (n *node) findChild(path string) *node {
	for _, n = range n.children {
		if n.isParameter() {
			paramEnd := strings.IndexByte(path, '/')
			if paramEnd == -1 { // Path ends with the parameter.
				if n.re != nil && !n.re.MatchString(path) {
					continue
				}
				return n
			}
			if n.re != nil && !n.re.MatchString(path[:paramEnd]) {
				continue
			}
			return n.findChild(path[paramEnd:])
		}
		if !strings.HasPrefix(path, n.s) { // Node doesn't match beginning of path.
			continue
		}
		if len(path) == len(n.s) { // Node matched until the end of path.
			return n
		}
		child := n.findChild(path[len(n.s):])
		if child == nil || child.handler == nil {
			if !n.isRoot && n.isWildcard() { // If node is a wildcard, don't use it when it's root.
				return n
			}
			continue // No match from children and current node is not a wildcard, maybe there is a parameter in next same-level node.
		}
		return child
	}
	return nil
}
152023
func (p *pageMeta) Param(key interface{}) (interface{}, error) {
	return resource.Param(p, p.s.Info.Params(), key)
}