Commit e0763ba8 authored by Russ Cox's avatar Russ Cox

godoc: serve index.html in place of directory listing, when present

R=gri
CC=golang-dev
https://golang.org/cl/181155
parent e0a40466
......@@ -943,6 +943,12 @@ func serveFile(c *http.Conn, r *http.Request) {
return
case ext == ".html":
if strings.HasSuffix(path, "/index.html") {
// We'll show index.html for the directory.
// Use the dir/ version as canonical instead of dir/index.html.
http.Redirect(c, r.URL.Path[0:len(r.URL.Path)-len("index.html")], http.StatusMovedPermanently)
return
}
serveHTMLDoc(c, r, path)
return
......@@ -958,6 +964,10 @@ func serveFile(c *http.Conn, r *http.Request) {
}
if dir != nil && dir.IsDirectory() {
if index := path + "/index.html"; isTextFile(index) {
serveHTMLDoc(c, r, index)
return
}
serveDirectory(c, r, path)
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment