aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/static
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-05-27 22:36:50 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-05-27 22:42:16 +0200
commit2dd4cf35aab8324608a83d337459fd8354521b92 (patch)
treeb65ecc803260bc268332fb2fbce83ab5dd209dbc /pkg/handler/static
parent60e8e751c76d949a28eefe0c5462e0cf17337217 (diff)
downloadcerrado-2dd4cf35aab8324608a83d337459fd8354521b92.tar.gz
cerrado-2dd4cf35aab8324608a83d337459fd8354521b92.tar.bz2
cerrado-2dd4cf35aab8324608a83d337459fd8354521b92.zip
feat: Wraps handler into its own package
Although this creates more complex folder structure will allow in the feature for a easier testing of those given handlers.
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
+}