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/view/filesystem.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'pkg/view/filesystem.go') 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, -- cgit v1.2.3