From 041252cfc80f6ac996fadf083f13c101d38450dc Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Sun, 1 May 2016 06:56:52 -0700 Subject: [PATCH] Fixed #496 Signed-off-by: Vishal Rana --- middleware/static.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/middleware/static.go b/middleware/static.go index 4bb41bcb..05e9e625 100644 --- a/middleware/static.go +++ b/middleware/static.go @@ -80,7 +80,12 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc { // TODO: search all files file = path.Join(file, config.Index[0]) f, err = fs.Open(file) - if err != nil && config.Browse { + if err == nil { + // Index file + if fi, err = f.Stat(); err != nil { + return err + } + } else if err != nil && config.Browse { dirs, err := d.Readdir(-1) if err != nil { return err @@ -105,9 +110,8 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc { } _, err = fmt.Fprintf(res, "\n") return err - } - if fi, err = f.Stat(); err != nil { // Index file - return err + } else { + return next(c) } } return c.ServeContent(f, fi.Name(), fi.ModTime())