mirror of
https://github.com/golang/go
synced 2024-11-22 09:04:42 -07:00
godoc: serve index.html in place of directory listing, when present
R=gri CC=golang-dev https://golang.org/cl/181155
This commit is contained in:
parent
e0a4046662
commit
e0763ba8e7
@ -943,6 +943,12 @@ func serveFile(c *http.Conn, r *http.Request) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
case ext == ".html":
|
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)
|
serveHTMLDoc(c, r, path)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -958,6 +964,10 @@ func serveFile(c *http.Conn, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dir != nil && dir.IsDirectory() {
|
if dir != nil && dir.IsDirectory() {
|
||||||
|
if index := path + "/index.html"; isTextFile(index) {
|
||||||
|
serveHTMLDoc(c, r, index)
|
||||||
|
return
|
||||||
|
}
|
||||||
serveDirectory(c, r, path)
|
serveDirectory(c, r, path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user