1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-24 08:22:21 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-06-19 15:37:26 -07:00
parent 9c7053cb7c
commit d04651dc2a
3 changed files with 11 additions and 2 deletions

View File

@ -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)

View File

@ -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) {

View File

@ -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());
});