net/http: FileServer() directory listings cannot be styled #29945
Labels
FeatureRequest
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Proposal
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Developing an app using http.FileServer(), it became apparent by examining the net/http/fs.go dirList() function, which is used by serveFile() to emit HTML listings of directories, that the format/styling of these directory pages is hardcoded, with no facility for callers to apply basic header, footer or link styling to allow consistency with the rest of custom endpoints an application might serve, by http.HandleFunc() etc.
Basic styling allowing applications to override the basic HTTP headers, HTML header, body and footer portions of a served directory listing page would fill a significant gap in the customization facilities of the core http package, such that applications serving custom endpoints as well as bare filesystem trees could have a consistent presentation (eg. vendor backgrounds, alink styling, legal disclaimers when browsing directories, and so on).
What did you expect to see?
Some facility for applications to apply basic styling to directory pages served by http.FileServer().
What did you see instead?
Hardcoded <pre>...</pre> blocks emitted by dirList(), for directory listings, and no control over HTTP headers or alink styles.
The text was updated successfully, but these errors were encountered: