mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 12:31:58 +00:00
A tiny improvement to the context.ServeFile
Former-commit-id: e9eaa1f51c08ec74cbc17c7cd3f62d557faf23a0
This commit is contained in:
@@ -2317,15 +2317,10 @@ func (ctx *context) ServeFile(filename string, gzipCompression bool) error {
|
||||
defer f.Close()
|
||||
fi, _ := f.Stat()
|
||||
if fi.IsDir() {
|
||||
filename = path.Join(filename, "index.html")
|
||||
f, err = os.Open(filename)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%d", 404)
|
||||
}
|
||||
fi, _ = f.Stat()
|
||||
return ctx.ServeFile(path.Join(filename, "index.html"), gzipCompression)
|
||||
}
|
||||
return ctx.ServeContent(f, fi.Name(), fi.ModTime(), gzipCompression)
|
||||
|
||||
return ctx.ServeContent(f, fi.Name(), fi.ModTime(), gzipCompression)
|
||||
}
|
||||
|
||||
// SendFile sends file for force-download to the client
|
||||
|
||||
Reference in New Issue
Block a user