Append index.html to directories when resolving paths.
This commit is contained in:
parent
06aafc8261
commit
309dd05f4d
|
@ -57,6 +57,15 @@ func GetHandler(config Config) http.HandlerFunc {
|
|||
http.Error(w, "Permission denied.", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
// Add index.html to directory paths, if it exists
|
||||
if info.IsDir() {
|
||||
index_path := filepath.Join(path, "index.html")
|
||||
index_info, err := os.Stat(index_path)
|
||||
if !os.IsNotExist(err) {
|
||||
path = index_path
|
||||
info = index_info
|
||||
}
|
||||
}
|
||||
// Fail if file is not world readable
|
||||
if uint64(info.Mode().Perm())&0444 != 0444 {
|
||||
http.Error(w, "File not world-readable.", http.StatusForbidden)
|
||||
|
|
Loading…
Reference in New Issue