From 5168a9476f0e83264ecafc85bc9145e8bdcbb8dc Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sat, 5 Aug 2023 19:26:29 +0200 Subject: 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. --- pkg/ext/fileserver.go | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 pkg/ext/fileserver.go (limited to 'pkg/ext/fileserver.go') 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) - } -} -- cgit v1.2.3