Skip to content

Commit

Permalink
Fixed labstack#496
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed May 1, 2016
1 parent b53170a commit 041252c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions middleware/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -105,9 +110,8 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc {
}
_, err = fmt.Fprintf(res, "</pre>\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())
Expand Down

0 comments on commit 041252c

Please sign in to comment.