aboutsummaryrefslogtreecommitdiff
path: root/pkg/ext
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-06-25 16:03:36 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-06-25 16:12:05 +0200
commitd6cf67b3d7747b6274d92e394d75d348060fa5f5 (patch)
tree8c48f947e7ab732a38b15eab6a898cb14caa1669 /pkg/ext
parent57b41ad766b3c4505672c12f058f10c7a132dd5b (diff)
downloadlens-d6cf67b3d7747b6274d92e394d75d348060fa5f5.tar.gz
lens-d6cf67b3d7747b6274d92e394d75d348060fa5f5.tar.bz2
lens-d6cf67b3d7747b6274d92e394d75d348060fa5f5.zip
feat: Add static file to output bin
Now the final binary has a standalone web server including necessary static file.
Diffstat (limited to 'pkg/ext')
-rw-r--r--pkg/ext/fileserver.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/ext/fileserver.go b/pkg/ext/fileserver.go
new file mode 100644
index 0000000..fdea08e
--- /dev/null
+++ b/pkg/ext/fileserver.go
@@ -0,0 +1,18 @@
+package ext
+
+import (
+ "io/fs"
+
+ "github.com/valyala/fasthttp"
+)
+
+type FileSystem interface {
+ Open(name string) (fs.File, error)
+}
+
+func FileServer(rootFS FileSystem, rootPath string) fasthttp.RequestHandler {
+ return func(r *fasthttp.RequestCtx) {
+ path := r.UserValue("filepath").(string)
+ r.SendFile(rootPath + path)
+ }
+}