Bumps [github.com/labstack/echo/v4](https://github.com/labstack/echo) from 4.6.1 to 4.7.2. - [Release notes](https://github.com/labstack/echo/releases) - [Changelog](https://github.com/labstack/echo/blob/master/CHANGELOG.md) - [Commits](https://github.com/labstack/echo/compare/v4.6.1...v4.7.2) --- updated-dependencies: - dependency-name: github.com/labstack/echo/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Ondřej Budai <ondrej@budai.cz>
33 lines
549 B
Go
33 lines
549 B
Go
//go:build !go1.16
|
|
// +build !go1.16
|
|
|
|
package echo
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func (c *context) File(file string) (err error) {
|
|
f, err := os.Open(file)
|
|
if err != nil {
|
|
return NotFoundHandler(c)
|
|
}
|
|
defer f.Close()
|
|
|
|
fi, _ := f.Stat()
|
|
if fi.IsDir() {
|
|
file = filepath.Join(file, indexPage)
|
|
f, err = os.Open(file)
|
|
if err != nil {
|
|
return NotFoundHandler(c)
|
|
}
|
|
defer f.Close()
|
|
if fi, err = f.Stat(); err != nil {
|
|
return
|
|
}
|
|
}
|
|
http.ServeContent(c.Response(), c.Request(), fi.Name(), fi.ModTime(), f)
|
|
return
|
|
}
|