From e3389d2df32d1d3377aea70d72e8bd0c7c516427 Mon Sep 17 00:00:00 2001 From: Gianni Carafa Date: Thu, 2 Nov 2023 20:21:24 +0100 Subject: [PATCH] simplify Noform Option --- cmd/main.go | 6 +----- handlers/form.go | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 851c35a..ef6d404 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -48,11 +48,7 @@ func main() { }) } - if os.Getenv("DISABLE_FORM") != "true" { - app.Get("/", handlers.Form) - } else { - app.Get("/", handlers.NoForm) - } + app.Get("/", handlers.Form) app.Get("raw/*", handlers.Raw) app.Get("api/*", handlers.Api) diff --git a/handlers/form.go b/handlers/form.go index 70df457..cab5138 100644 --- a/handlers/form.go +++ b/handlers/form.go @@ -1,16 +1,20 @@ package handlers -import "github.com/gofiber/fiber/v2" +import ( + "os" -func NoForm(c *fiber.Ctx) error { - c.Set("Content-Type", "text/html") - c.SendStatus(fiber.StatusNotFound) - return c.SendString("Form Disabled") -} + "github.com/gofiber/fiber/v2" +) func Form(c *fiber.Ctx) error { - c.Set("Content-Type", "text/html") - return c.SendString(html) + if os.Getenv("DISABLE_FORM") == "true" { + c.Set("Content-Type", "text/html") + c.SendStatus(fiber.StatusNotFound) + return c.SendString("Form Disabled") + } else { + c.Set("Content-Type", "text/html") + return c.SendString(html) + } } const html = `