diff --git a/cmds/server.go b/cmds/server.go index c39f233..1e368ce 100644 --- a/cmds/server.go +++ b/cmds/server.go @@ -116,7 +116,7 @@ Starting weiro without any arguments will start the server. app.Post("/login", lh.DoLogin) app.Post("/logout", lh.Logout) - siteGroup := app.Group("/sites/:siteID", middleware.RequireUser(svcs.Auth), middleware.RequiresSite(svcs.Sites)) + siteGroup := app.Group("/sites/:siteID", middleware.LogErrors(), middleware.RequireUser(svcs.Auth), middleware.RequiresSite(svcs.Sites)) siteGroup.Get("/posts", ph.Index) siteGroup.Get("/posts/new", ph.New) diff --git a/config/config.go b/config/config.go index 56585a7..d607b1b 100644 --- a/config/config.go +++ b/config/config.go @@ -9,7 +9,7 @@ import ( type Config struct { DataDir string `env:"DATA_DIR"` - ScratchDir string `env:"SCRATCH_DIR"` + ScratchDir string `env:"SCRATCH_DIR,default=/tmp"` SiteDomain string `env:"SITE_DOMAIN"` LoginLocked bool `env:"LOGIN_LOCKED,default=false"` Env string `env:"ENV,default=prod"` diff --git a/handlers/middleware/errlog.go b/handlers/middleware/errlog.go new file mode 100644 index 0000000..5b6dfa6 --- /dev/null +++ b/handlers/middleware/errlog.go @@ -0,0 +1,17 @@ +package middleware + +import ( + "log" + + "github.com/gofiber/fiber/v3" +) + +func LogErrors() func(c fiber.Ctx) error { + return func(c fiber.Ctx) error { + if err := c.Next(); err != nil { + log.Printf("error: %v\n", err) + return err + } + return nil + } +}