simplify Noform Option

This commit is contained in:
Gianni Carafa
2023-11-02 20:21:24 +01:00
parent b786796595
commit e3389d2df3
2 changed files with 13 additions and 13 deletions

View File

@@ -48,11 +48,7 @@ func main() {
}) })
} }
if os.Getenv("DISABLE_FORM") != "true" { app.Get("/", handlers.Form)
app.Get("/", handlers.Form)
} else {
app.Get("/", handlers.NoForm)
}
app.Get("raw/*", handlers.Raw) app.Get("raw/*", handlers.Raw)
app.Get("api/*", handlers.Api) app.Get("api/*", handlers.Api)

View File

@@ -1,16 +1,20 @@
package handlers package handlers
import "github.com/gofiber/fiber/v2" import (
"os"
func NoForm(c *fiber.Ctx) error { "github.com/gofiber/fiber/v2"
c.Set("Content-Type", "text/html") )
c.SendStatus(fiber.StatusNotFound)
return c.SendString("Form Disabled")
}
func Form(c *fiber.Ctx) error { func Form(c *fiber.Ctx) error {
c.Set("Content-Type", "text/html") if os.Getenv("DISABLE_FORM") == "true" {
return c.SendString(html) 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 = ` const html = `