1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 13:00:54 +00:00

Merge pull request #2062 from Maxgis/feature_static

减少没有必要的代码以及静态前缀前面有/
This commit is contained in:
astaxie 2016-07-25 22:19:38 +08:00 committed by GitHub
commit 02330c6085
2 changed files with 3 additions and 6 deletions

View File

@ -233,9 +233,9 @@ func assignConfig(ac config.Configer) error {
sds := strings.Fields(sd)
for _, v := range sds {
if url2fsmap := strings.SplitN(v, ":", 2); len(url2fsmap) == 2 {
BConfig.WebConfig.StaticDir["/"+strings.TrimRight(url2fsmap[0], "/")] = url2fsmap[1]
BConfig.WebConfig.StaticDir["/"+strings.Trim(url2fsmap[0], "/")] = url2fsmap[1]
} else {
BConfig.WebConfig.StaticDir["/"+strings.TrimRight(url2fsmap[0], "/")] = url2fsmap[0]
BConfig.WebConfig.StaticDir["/"+strings.Trim(url2fsmap[0], "/")] = url2fsmap[0]
}
}
}

View File

@ -163,13 +163,10 @@ func searchFile(ctx *context.Context) (string, os.FileInfo, error) {
return filePath, fi, nil
}
}
return "", nil, errors.New(requestPath + " file not find")
return "", nil, errNotStaticRequest
}
for prefix, staticDir := range BConfig.WebConfig.StaticDir {
if len(prefix) == 0 {
continue
}
if !strings.Contains(requestPath, prefix) {
continue
}