mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:20:55 +00:00
fix not found when has mulit static dir
robot &robots
This commit is contained in:
parent
6c62198b59
commit
727d2f9ea1
@ -31,6 +31,7 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
requestPath := path.Clean(ctx.Input.Request.URL.Path)
|
requestPath := path.Clean(ctx.Input.Request.URL.Path)
|
||||||
|
i := 0
|
||||||
for prefix, staticDir := range StaticDir {
|
for prefix, staticDir := range StaticDir {
|
||||||
if len(prefix) == 0 {
|
if len(prefix) == 0 {
|
||||||
continue
|
continue
|
||||||
@ -41,8 +42,13 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
http.ServeFile(ctx.ResponseWriter, ctx.Request, file)
|
http.ServeFile(ctx.ResponseWriter, ctx.Request, file)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
http.NotFound(ctx.ResponseWriter, ctx.Request)
|
i++
|
||||||
return
|
if i == len(StaticDir) {
|
||||||
|
http.NotFound(ctx.ResponseWriter, ctx.Request)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(requestPath, prefix) {
|
if strings.HasPrefix(requestPath, prefix) {
|
||||||
|
Loading…
Reference in New Issue
Block a user