1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 20:10:56 +00:00

减少没有必要的代码以及静态前缀前面有/

This commit is contained in:
Maxgis 2016-07-24 15:29:34 +08:00
parent 56dc9bf622
commit 33ef34b95d
2 changed files with 3 additions and 7 deletions

View File

@ -256,13 +256,12 @@ func parseConfig(appConfigPath string) (err error) {
sds := strings.Fields(sd) sds := strings.Fields(sd)
for _, v := range sds { for _, v := range sds {
if url2fsmap := strings.SplitN(v, ":", 2); len(url2fsmap) == 2 { 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 { } else {
BConfig.WebConfig.StaticDir["/"+strings.TrimRight(url2fsmap[0], "/")] = url2fsmap[0] BConfig.WebConfig.StaticDir["/"+strings.Trim(url2fsmap[0], "/")] = url2fsmap[0]
} }
} }
} }
if sgz := AppConfig.String("StaticExtensionsToGzip"); sgz != "" { if sgz := AppConfig.String("StaticExtensionsToGzip"); sgz != "" {
extensions := strings.Split(sgz, ",") extensions := strings.Split(sgz, ",")
fileExts := []string{} fileExts := []string{}

View File

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