From 349a3d1ff36a436261b1b65b870f8f262f06584f Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sun, 26 May 2024 00:05:31 +0200 Subject: feat: Add bare bones project list --- pkg/handler/static.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pkg/handler/static.go (limited to 'pkg/handler/static.go') diff --git a/pkg/handler/static.go b/pkg/handler/static.go new file mode 100644 index 0000000..9f312f4 --- /dev/null +++ b/pkg/handler/static.go @@ -0,0 +1,18 @@ +package handler + +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 +} -- cgit v1.2.3