Motivation
sim is a thin wrapper over net/http.ServeMux, so static file serving
already works today via raw stdlib composition:
app := sim.NewApp()
app.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("public"))))
Do we want dedicated helpers at all — and if so, how many? Every method added to the API surface is a contract we maintain: docs, tests, and
naming decisions all follow.
How other frameworks do it (verified from source)
| Framework |
Methods |
Directory listing default |
index.html |
| gin |
Static / StaticFS / StaticFile / StaticFileFS |
disabled (Dir(root,false)/OnlyFilesFS) |
yes |
| echo |
Static / StaticFS / File / FileFS |
none (never enumerates) |
yes |
| fiber |
Static (1, config-driven) |
disabled (Browse:false, opt-in) |
yes (Index:"index.html") |
| chi / mux |
— |
stdlib default (enabled) |
yes |
Motivation
sim is a thin wrapper over
net/http.ServeMux, so static file servingalready works today via raw stdlib composition:
Do we want dedicated helpers at all — and if so, how many? Every method added to the API surface is a contract we maintain: docs, tests, and
naming decisions all follow.
How other frameworks do it (verified from source)
Static/StaticFS/StaticFile/StaticFileFSDir(root,false)/OnlyFilesFS)Static/StaticFS/File/FileFSStatic(1, config-driven)Browse:false, opt-in)Index:"index.html")