aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/static
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-01 20:20:00 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-06-01 20:20:00 +0200
commitd0e0c1eb99303e1000140d4b98c610077278dc42 (patch)
tree30f9bc8dba73df5a6bdf2fc20041120881fe4e57 /pkg/handler/static
parente3705f35c642e578625ce4574d189fa0b0869403 (diff)
downloadcerrado-d0e0c1eb99303e1000140d4b98c610077278dc42.tar.gz
cerrado-d0e0c1eb99303e1000140d4b98c610077278dc42.tar.bz2
cerrado-d0e0c1eb99303e1000140d4b98c610077278dc42.zip
ref: Remove mux
Diffstat (limited to 'pkg/handler/static')
-rw-r--r--pkg/handler/static/handler.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/handler/static/handler.go b/pkg/handler/static/handler.go
index 6a826cc..a8b4583 100644
--- a/pkg/handler/static/handler.go
+++ b/pkg/handler/static/handler.go
@@ -7,12 +7,15 @@ import (
"git.gabrielgio.me/cerrado/static"
)
-func NewStaticHander(prefix string) (http.Handler, error) {
+func ServeStaticHandler() (func(w http.ResponseWriter, r *http.Request), error) {
staticFs, err := fs.Sub(static.Static, ".")
if err != nil {
return nil, err
}
- handler := http.StripPrefix(prefix, http.FileServer(http.FS(staticFs)))
- return handler, nil
+ return func(w http.ResponseWriter, r *http.Request) {
+ f := r.PathValue("file")
+
+ http.ServeFileFS(w, r, staticFs, f)
+ }, nil
}