aboutsummaryrefslogtreecommitdiff
path: root/pkg/view/filesystem.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/view/filesystem.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/view/filesystem.go')
-rw-r--r--pkg/view/filesystem.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/view/filesystem.go b/pkg/view/filesystem.go
index 6a01117..d49ad4f 100644
--- a/pkg/view/filesystem.go
+++ b/pkg/view/filesystem.go
@@ -1,7 +1,7 @@
package view
import (
- "github.com/valyala/fasthttp"
+ "net/http"
"git.sr.ht/~gabrielgio/img/pkg/database/repository"
"git.sr.ht/~gabrielgio/img/pkg/ext"
@@ -31,21 +31,23 @@ func NewFileSystemView(
}
}
-func (self *FileSystemView) Index(ctx *fasthttp.RequestCtx) error {
- pathValue := string(ctx.FormValue("path"))
- token := ext.GetTokenFromCtx(ctx)
+func (self *FileSystemView) Index(w http.ResponseWriter, r *http.Request) error {
+ var (
+ pathValue = r.FormValue("path")
+ token = ext.GetTokenFromCtx(w, r)
+ )
- page, err := self.fsService.GetPage(ctx, token.UserID, pathValue)
+ page, err := self.fsService.GetPage(r.Context(), token.UserID, pathValue)
if err != nil {
return err
}
- settings, err := self.settings.Load(ctx)
+ settings, err := self.settings.Load(r.Context())
if err != nil {
return err
}
- templates.WritePageTemplate(ctx, &templates.FilePage{
+ templates.WritePageTemplate(w, &templates.FilePage{
Page: page,
ShowMode: settings.ShowMode,
ShowOwner: settings.ShowOwner,