summaryrefslogtreecommitdiff
path: root/static.go
diff options
context:
space:
mode:
authorherkulessi <git@herkulessi.de>2025-08-20 20:13:09 +0200
committerherkulessi <git@herkulessi.de>2025-08-20 20:13:09 +0200
commit32e7fe5f94eee7e08f048d1ead1e7e82f29c46d6 (patch)
treebb93bfa26873ad55b51b12398e837bd2ea880b50 /static.go
Initial commit of libmkwebpage
Diffstat (limited to 'static.go')
-rw-r--r--static.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/static.go b/static.go
new file mode 100644
index 0000000..04c0fe6
--- /dev/null
+++ b/static.go
@@ -0,0 +1,14 @@
+package libmkwebpage
+
+import (
+ "embed"
+ "io/fs"
+ "net/http"
+)
+
+func (w *Webpage) NewStaticFiles(pattern string, static embed.FS, dynamic fs.FS) *Webpage {
+ w.HandlerDynamic("GET "+pattern, http.FileServerFS(dynamic))
+ w.HandlerStatic("GET "+pattern, http.FileServerFS(static))
+ w.staticFilePrefix = pattern
+ return w
+}