mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
parent
9c7053cb7c
commit
d04651dc2a
6
echo.go
6
echo.go
@ -338,7 +338,11 @@ func serveFile(dir, file string, c *Context) error {
|
||||
|
||||
fi, _ := f.Stat()
|
||||
if fi.IsDir() {
|
||||
return NewHTTPError(http.StatusForbidden)
|
||||
f, err = fs.Open("index.html")
|
||||
if err != nil {
|
||||
return NewHTTPError(http.StatusForbidden)
|
||||
}
|
||||
fi, _ = f.Stat()
|
||||
}
|
||||
|
||||
http.ServeContent(c.response, c.request, fi.Name(), fi.ModTime(), f)
|
||||
|
@ -75,6 +75,11 @@ func TestEchoStatic(t *testing.T) {
|
||||
e.Static("/scripts", "examples/website/public/scripts")
|
||||
c, _ = request(GET, "/scripts", e)
|
||||
assert.Equal(t, http.StatusForbidden, c)
|
||||
|
||||
// Directory with index.html
|
||||
e.Static("/", "examples/website/public")
|
||||
c, _ = request(GET, "/", e)
|
||||
assert.Equal(t, http.StatusOK, c)
|
||||
}
|
||||
|
||||
func TestEchoMiddleware(t *testing.T) {
|
||||
|
@ -5,6 +5,6 @@ var ghPages = require('gulp-gh-pages');
|
||||
gulp.task('build', shell.task('mkdocs build --clean'))
|
||||
|
||||
gulp.task('deploy',['build'], function() {
|
||||
return gulp.src('./site/**/*')
|
||||
return gulp.src('site/**/*')
|
||||
.pipe(ghPages());
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user