// Prefix set a default prefix for all routes registred on the router
548971
func (m *Mux) Prefix(p string) *Mux {
	m.prefix = strings.TrimSuffix(p, "/")
	return m
}
1168281
func (s *ReplicationRuleFilter) SetPrefix(v string) *ReplicationRuleFilter {
	s.Prefix = &v
	return s
}
975099
func (r *Realize) Prefix(input string) string {
	if len(input) > 0 {
		return fmt.Sprint(Yellow.Bold("["), strings.ToUpper(RPrefix), Yellow.Bold("]"), " : ", input)
	}
	return input
}
446543
func (s *ListMultipartUploadsInput) SetPrefix(v string) *ListMultipartUploadsInput {
	s.Prefix = &v
	return s
}
1025343
func (n *node) addRoute(path string, handle RequestHandler, r *router, prefixes []string) {
	fullPath := path
	n.priority++
	numParams := countParams(path)
	if n.router == nil {
		n.router = r
	}

	// non-empty tree
	if len(n.path) > zero || len(n.children) > zero {
	walk:
		for {
			// Update maxParams of the current node
			if numParams > n.maxParams {
				n.maxParams = numParams
			}

			// Find the longest common prefix.
			// This also implies that the common prefix contains no ':' or '*'
			// since the existing key can't contain those chars.
			i := zero
			max := min(len(path), len(n.path))
			for i < max && path[i] == n.path[i] {
				i++
			}

			// Split edge
			if i < len(n.path) {
				child := node{
					path:      n.path[i:],
					wildChild: n.wildChild,
					nType:     static,
					indices:   n.indices,
					children:  n.children,
					handle:    n.handle,
					priority:  n.priority - one,
					router:    n.router,
					prefixes:  prefixes,
				}

				// Update maxParams (max of all children)
				for i := range child.children {
					if child.children[i].maxParams > child.maxParams {
						child.maxParams = child.children[i].maxParams
					}
				}

				n.children = []*node{&child}
				// []byte for proper unicode char conversion, see #65
				n.indices = string([]byte{n.path[i]})
				n.path = path[:i]
				n.handle = nil
				n.wildChild = false
			}

			// Make new node a child of this node
			if i < len(path) {
				path = path[i:]

				if n.wildChild {
					n = n.children[zero]
					n.priority++

					// Update maxParams of the child node
					if numParams > n.maxParams {
						n.maxParams = numParams
					}
					numParams--

					// Check if the wildcard matches
					if len(path) >= len(n.path) && n.path == path[:len(n.path)] &&
						// Check for longer wildcard, e.g. :name and :names
						(len(n.path) >= len(path) || path[len(n.path)] == SlashByte) {
						continue walk
					} else {
						// Wildcard conflict
						pathSeg := strings.SplitN(path, PathSlash, 2)[zero]
						prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
						panic("'" + pathSeg +
							"' in new path '" + fullPath +
							"' conflicts with existing wildcard '" + n.path +
							"' in existing prefix '" + prefix +
							"'")
					}
				}

				c := path[zero]

				// slash after param
				if n.nType == param && c == SlashByte && len(n.children) == one {
					n = n.children[zero]
					n.priority++
					continue walk
				}

				// Check if a child with the next path byte exists
				for i := zero; i < len(n.indices); i++ {
					if c == n.indices[i] {
						i = n.incrementChildPrio(i)
						n = n.children[i]
						continue walk
					}
				}

				// Otherwise insert it
				if c != ':' && c != '*' {
					// []byte for proper unicode char conversion, see #65
					n.indices += string([]byte{c})
					child := &node{
						maxParams: numParams,
						router:    n.router,
					}
					n.children = append(n.children, child)
					n.incrementChildPrio(len(n.indices) - one)
					n = child
				}
				n.insertChild(numParams, path, fullPath, handle, prefixes)
				return

			} else if i == len(path) { // Make node a (in-path) leaf
				if n.handle != nil {
					panic("a handle is already registered for path '" + fullPath + "'")
				}
				n.handle = handle
			}
			return
		}
	} else { // Empty tree
		n.insertChild(numParams, path, fullPath, handle, prefixes)
		n.nType = root
	}
}
1317881
func (r *Router) Sub(path string) *SubRouter {
	return &SubRouter{
		prefix:   path,
		parent:   r,
		prefixes: []string{path},
	}
}
833528
func (s *JobReport) SetPrefix(v string) *JobReport {
	s.Prefix = &v
	return s
}
668909
func hasPathPrefix(s, prefix string) bool {
	switch {
	default:
		return false
	case len(s) == len(prefix):
		return s == prefix
	case len(s) > len(prefix):
		if prefix != "" && prefix[len(prefix)-1] == '/' {
			return strings.HasPrefix(s, prefix)
		}
		return s[len(prefix)] == '/' && s[:len(prefix)] == prefix
	}
}
326238
func (s *CommonPrefix) SetPrefix(v string) *CommonPrefix {
	s.Prefix = &v
	return s
}
681410
func (s *StreamingLoggingConfig) SetPrefix(v string) *StreamingLoggingConfig {
	s.Prefix = &v
	return s
}
565273
func (j *Jobs) PrefixList(prefix string) ([]*JobListStub, *QueryMeta, error) {
	return j.List(&QueryOptions{Prefix: prefix})
}
8321
func (s *ListObjectsV2Input) SetPrefix(v string) *ListObjectsV2Input {
	s.Prefix = &v
	return s
}
924902
func (s *LifecycleRuleFilter) SetPrefix(v string) *LifecycleRuleFilter {
	s.Prefix = &v
	return s
}
68295
func Path(s, prefix string) string {
	l := dns.SplitDomainName(s)
	for i, j := 0, len(l)-1; i < j; i, j = i+1, j-1 {
		l[i], l[j] = l[j], l[i]
	}
	return path.Join(append([]string{"/" + prefix + "/"}, l...)...)
}
558784
func ParsePrefix(line string) *Prefix {
	// Start by creating an Prefix with nothing but the host
	id := &Prefix{
		Name: line,
	}

	uh := strings.SplitN(id.Name, "@", 2)
	if len(uh) == 2 {
		id.Name, id.Host = uh[0], uh[1]
	}

	nu := strings.SplitN(id.Name, "!", 2)
	if len(nu) == 2 {
		id.Name, id.User = nu[0], nu[1]
	}

	return id
}
358894
func (r *SubRouter) PATCH(route string, handler interface{}) *SubRouter {
	route = r.prefixedRoute(route)
	if r.parent != nil {
		r.parent.handleReg(MethodPATCH, route, handler, r.prefixes)
	}

	return r
}
1334038
func PrefixKey(handler cfg.Handler, prefix string) cfg.Handler {
	return Apply(func(key string) (string, error) { return fmt.Sprintf("%s%s", prefix, key), nil }, nil, handler)
}