mirror of
https://github.com/astaxie/beego.git
synced 2024-10-31 23:50:54 +00:00
Merge pull request #2062 from Maxgis/feature_static
减少没有必要的代码以及静态前缀前面有/
This commit is contained in:
commit
02330c6085
@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user