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. --- cmd/server/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cmd/server') diff --git a/cmd/server/main.go b/cmd/server/main.go index 385c54f..39987e5 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -4,13 +4,13 @@ import ( "context" "encoding/hex" "errors" + "net/http" "os" "os/signal" - "github.com/fasthttp/router" + "github.com/gorilla/mux" "github.com/sirupsen/logrus" flag "github.com/spf13/pflag" - "github.com/valyala/fasthttp" "gorm.io/driver/mysql" "gorm.io/driver/postgres" "gorm.io/driver/sqlite" @@ -71,8 +71,8 @@ func main() { panic("failed to decode key database: " + err.Error()) } - r := router.New() - r.GET("/static/{filepath:*}", ext.FileServer(static.Static)) + r := mux.NewRouter() + r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.FS(static.Static)))) // repository var ( @@ -122,7 +122,7 @@ func main() { // worker var ( - serverWorker = worker.NewServerWorker(&fasthttp.Server{Handler: r.Handler, NoDefaultContentType: true}) + serverWorker = worker.NewServerWorker(&http.Server{Handler: r, Addr: "0.0.0.0:8080"}) fileWorker = worker.NewWorkerFromChanProcessor[string]( fileScanner, scheduler, -- cgit v1.2.3