// URLPath 生成当前Module网址
971844
func (c *Context) URLPath(ppath string, args ...map[string]interface{}) string {
	if len(ppath) == 0 {
		if len(c.ControllerName) > 0 {
			ppath = c.ControllerName + `/`
		}
		ppath += c.ActionName
		return c.Application.URLBuilder.BuildFromPath(c.Module.Name+`/`+ppath, args...)
	}
	ppath = strings.TrimLeft(ppath, `/`)
	return c.Application.URLBuilder.BuildFromPath(c.Module.Name+`/`+ppath, args...)
}
126450
func DropURLRegex(URLPath, param string) string {
	r := regexp.MustCompile(`\{token:\[A-z0-9]\{64\}}`)
	return r.ReplaceAllLiteralString(URLPath, param)
}
469581
func FetchURL(urlPath string) string {
	response, err := http.Get(fmt.Sprintf("%s%s", ServerAddress, urlPath))
	if err != nil {
		return ""
	}
	defer response.Body.Close()
	b, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return ""
	}
	return string(b)
}
714567
func URLParam(name string, req *http.Request) string {
	return chi.URLParam(req, name)
}
668344
func (c *Context) ModuleURL(mod string, ctl string, act string, args ...interface{}) string {
	return c.Application.URLBuilder.Build(mod, ctl, act, args...)
}
33955
func ModuleFromPath(path string, addGopathToPath bool) (module *Module) {
	path = filepath.ToSlash(path)
	gopathList := filepath.SplitList(build.Default.GOPATH)
	// Strip away the vendor folder
	if i := strings.Index(path, "/vendor/"); i > 0 {
		path = path[i+len("vendor/"):]
	}

	// See if the path exists in the module based
	for i := range Modules {
		if addGopathToPath {
			for _, gopath := range gopathList {
				if strings.Contains(filepath.ToSlash(filepath.Clean(filepath.Join(gopath, "src", path))), Modules[i].Path) {
					module = Modules[i]
					break
				}
			}
		} else {
			if strings.Contains(path, Modules[i].ImportPath) {
				module = Modules[i]
				break
			}

		}

		if module != nil {
			break
		}
	}
	// Default to the app module if not found
	if module == nil {
		module = appModule
	}
	return
}
694217
func Path(path string) option {
	return func(c *sass) error {
		c.srcFile = path
		c.ctx.MainFile = path
		return nil
	}
}
279520
func urlPathEscape(in string) string {
	var u url.URL
	u.Path = in
	return u.String()
}
4343
func JujuMongodPath(v Version) string {
	return fmt.Sprintf("/usr/lib/juju/mongo%d.%d/bin/mongod", v.Major, v.Minor)
}
1179039
func (a App) ConfigPath(file string) string {
	return a.path("XDG_CONFIG_HOME", ConfigHome, file)
}
417041
func (r *Request) PathUrl(p string) (*url.URL, error) {
	return url.Parse(r.BaseURL + path.Join("/", p))
}
1122812
func (c *edgeCollection) relPath() string {
	escapedName := pathEscape(c.name)
	return path.Join(c.g.relPath(), "edge", escapedName)
}
960756
func (u *user) relPath() string {
	escapedName := pathEscape(u.data.Name)
	return path.Join("_api", "user", escapedName)
}
55547
func trimURLPath(path string) string {
	parts := strings.SplitN(strings.TrimPrefix(path, "/"), "/", 3)
	if len(parts) == 0 {
		return path
	}

	if parts[0] == "metrics" && len(parts) > 1 {
		return fmt.Sprintf("%s/%s", parts[0], parts[1])

	}
	return parts[0]
}
1094786
func configPath() string {
	var homeDir string
	// this fails for static binaries
	usr, err := user.Current()
	if err == nil {
		homeDir = usr.HomeDir
	}
	// this should work where we don't have static binaries
	if err != nil {
		homeDir = os.Getenv("HOME")
	}
	// panic if we've failed to retrieve the home directory
	if homeDir == "" {
		panic(errHomeDirectoryNotSet)
	}

	return usr.HomeDir + "/.netctl/config.json"
}
1255875
func Path(path string) RequestOption {
	return func(req *http.Request) (*http.Request, error) {
		if req.URL != nil {
			u, err := req.URL.Parse(path)
			if err != nil {
				return nil, err
			}

			req.URL = u
			return req, nil
		}

		u, err := url.Parse(path)
		if err != nil {
			return nil, err
		}

		req.URL = u
		return req, nil
	}
}
796335
func (r Route) StaticPath() string {
	src := r.tmpl.Src
	bidx := strings.IndexByte(src, '{')
	if bidx == -1 || len(src) <= bidx {
		return src // no dynamic part found
	}
	if bidx == 0 { // found at first index,
		// but never happens because of the prepended slash
		return "/"
	}

	return src[:bidx]
}