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)
} else {
app.Get("/", handlers.NoForm)
}
app.Get("raw/*", handlers.Raw)
app.Get("api/*", handlers.Api)

View File

@@ -1,17 +1,21 @@
package handlers
import "github.com/gofiber/fiber/v2"
import (
"os"
func NoForm(c *fiber.Ctx) error {
"github.com/gofiber/fiber/v2"
)
func Form(c *fiber.Ctx) error {
if os.Getenv("DISABLE_FORM") == "true" {
c.Set("Content-Type", "text/html")
c.SendStatus(fiber.StatusNotFound)
return c.SendString("Form Disabled")
}
func Form(c *fiber.Ctx) error {
} else {
c.Set("Content-Type", "text/html")
return c.SendString(html)
}
}
const html = `
<!DOCTYPE html>