aboutsummaryrefslogtreecommitdiff
path: root/pkg/ext/fileserver.go
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-05 19:26:29 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-05 19:26:29 +0200
commit5168a9476f0e83264ecafc85bc9145e8bdcbb8dc (patch)
tree5cd04e84f8aa427d274e16dd8cf507ff48468e07 /pkg/ext/fileserver.go
parent24c121a9ef229870f54de487de01c15a15ebbff1 (diff)
downloadlens-5168a9476f0e83264ecafc85bc9145e8bdcbb8dc.tar.gz
lens-5168a9476f0e83264ecafc85bc9145e8bdcbb8dc.tar.bz2
lens-5168a9476f0e83264ecafc85bc9145e8bdcbb8dc.zip
ref: Move net/http
I was young and naive, fasthttp does not fit my needs and make development slower. I'll move to net/http since it has a wider support and will spare some time on implementation detail things (like CSRF). It will allow me to reduce a bit of the code since there may be lib for handling cookie encryption and auth in general.
Diffstat (limited to 'pkg/ext/fileserver.go')
-rw-r--r--pkg/ext/fileserver.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/pkg/ext/fileserver.go b/pkg/ext/fileserver.go
deleted file mode 100644
index 87c1ae8..0000000
--- a/pkg/ext/fileserver.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package ext
-
-import (
- "io/fs"
- "mime"
- "path/filepath"
-
- "github.com/valyala/fasthttp"
-)
-
-type FileSystem interface {
- Open(name string) (fs.File, error)
-}
-
-// This is a VERY simple file server. It does not take a lot into consideration
-// and it should only be used to return small predictable files, like in the
-// static folder.
-func FileServer(rootFS FileSystem) fasthttp.RequestHandler {
- return func(ctx *fasthttp.RequestCtx) {
- path := ctx.UserValue("filepath").(string)
-
- f, err := rootFS.Open(path)
- if err != nil {
- InternalServerError(ctx, err)
- return
- }
- defer f.Close()
-
- m := mime.TypeByExtension(filepath.Ext(path))
- ctx.SetContentType(m)
- ctx.SetBodyStream(f, -1)
- }
-}