mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:26:26 +01:00
A tiny improvement to the context.ServeFile
Former-commit-id: e9eaa1f51c08ec74cbc17c7cd3f62d557faf23a0
This commit is contained in:
parent
38c6241055
commit
4ff0571785
|
@ -4,9 +4,8 @@ import (
|
|||
"github.com/kataras/iris/_examples/structuring/handler-based/bootstrap"
|
||||
)
|
||||
|
||||
// Configure registers the nessecary routes to the app.
|
||||
// Configure registers the necessary routes to the app.
|
||||
func Configure(b *bootstrap.Bootstrapper) {
|
||||
// routes
|
||||
b.Get("/", GetIndexHandler)
|
||||
b.Get("/follower/{id:long}", GetFollowerHandler)
|
||||
b.Get("/following/{id:long}", GetFollowingHandler)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user