727d2f9e by astaxie

fix not found when has mulit static dir

 robot &robots
1 parent 6c62198b
...@@ -31,6 +31,7 @@ func serverStaticRouter(ctx *context.Context) { ...@@ -31,6 +31,7 @@ func serverStaticRouter(ctx *context.Context) {
31 return 31 return
32 } 32 }
33 requestPath := path.Clean(ctx.Input.Request.URL.Path) 33 requestPath := path.Clean(ctx.Input.Request.URL.Path)
34 i := 0
34 for prefix, staticDir := range StaticDir { 35 for prefix, staticDir := range StaticDir {
35 if len(prefix) == 0 { 36 if len(prefix) == 0 {
36 continue 37 continue
...@@ -41,8 +42,13 @@ func serverStaticRouter(ctx *context.Context) { ...@@ -41,8 +42,13 @@ func serverStaticRouter(ctx *context.Context) {
41 http.ServeFile(ctx.ResponseWriter, ctx.Request, file) 42 http.ServeFile(ctx.ResponseWriter, ctx.Request, file)
42 return 43 return
43 } else { 44 } else {
45 i++
46 if i == len(StaticDir) {
44 http.NotFound(ctx.ResponseWriter, ctx.Request) 47 http.NotFound(ctx.ResponseWriter, ctx.Request)
45 return 48 return
49 } else {
50 continue
51 }
46 } 52 }
47 } 53 }
48 if strings.HasPrefix(requestPath, prefix) { 54 if strings.HasPrefix(requestPath, prefix) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!