aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/static
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/handler/static')
-rw-r--r--pkg/handler/static/handler.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/handler/static/handler.go b/pkg/handler/static/handler.go
new file mode 100644
index 0000000..6a826cc
--- /dev/null
+++ b/pkg/handler/static/handler.go
@@ -0,0 +1,18 @@
+package static
+
+import (
+ "io/fs"
+ "net/http"
+
+ "git.gabrielgio.me/cerrado/static"
+)
+
+func NewStaticHander(prefix string) (http.Handler, 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
+}