浏览代码

fix bug (#1682)

thinkerou 7 年之前
父节点
当前提交
98c7ac7202
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      routergroup.go

+ 4 - 1
routergroup.go

@@ -187,8 +187,11 @@ func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileS
 	fileServer := http.StripPrefix(absolutePath, http.FileServer(fs))
 
 	return func(c *Context) {
-		file := c.Param("filepath")
+		if _, nolisting := fs.(*onlyfilesFS); nolisting {
+			c.Writer.WriteHeader(http.StatusNotFound)
+		}
 
+		file := c.Param("filepath")
 		// Check if file exists and/or if we have permission to access it
 		if _, err := fs.Open(file); err != nil {
 			c.Writer.WriteHeader(http.StatusNotFound)