aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/static
diff options
context:
space:
mode:
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
}