diff --git a/README.md b/README.md index 313cf13..8f5e2c0 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ http://localhost:8080/raw/https://www.example.com | `USERPASS` | Enables Basic Auth, format `admin:123456` | `` | | `LOG_URLS` | Log fetched URL's | `true` | | `DISABLE_FORM` | Disables URL Form Frontpage | `false` | +| `FORM_PATH` | Path to custom Form HTML | `` | | `RULES_URL` | URL to a ruleset file | `https://raw.githubusercontent.com/kubero-dev/ladder/main/ruleset.yaml` | ### Ruleset diff --git a/handlers/form.go b/handlers/form.go index 49b9977..cdaa1ce 100644 --- a/handlers/form.go +++ b/handlers/form.go @@ -1,192 +1,31 @@ package handlers import ( + _ "embed" + "log" "os" "github.com/gofiber/fiber/v2" ) +//go:embed form.html +var formHtml string + 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") } else { + if os.Getenv("FORM_PATH") != "" { + dat, err := os.ReadFile(os.Getenv("FORM_PATH")) + if err != nil { + log.Println("ERROR: unable to load custom form", err) + } else { + formHtml = string(dat) + } + } c.Set("Content-Type", "text/html") - return c.SendString(html) + return c.SendString(formHtml) } } - -const html = ` - - -
- -