diff --git a/app.go b/app.go index 2f2e8b76055aa48c8dedceccab3b1f27a846deba..08cd160f47566b06b44eeb44044e416c8263ad8d 100644 --- a/app.go +++ b/app.go @@ -54,11 +54,8 @@ func serve(sig chan os.Signal, db *leveldb.DB) error { confEnv[hCaptchaSiteKey][0], confEnv[hCaptchaSecretKey][0]) } - // /register - routeRegister(app, db, captcha) - - // /hcaptcha-site-key - routeHCaptchaSiteKey(app, !hCaptchaEnable, conf[hCaptchaSiteKey]) + routeHCaptchaSiteKey(app, "/api", !hCaptchaEnable, conf[hCaptchaSiteKey]) + routeRegister(app, "/api/register", db, captcha) // graceful shutdown go func() { diff --git a/captcha.go b/captcha.go index f2d517d514d49c5f41f1f7d69333fe2023b58f15..d8e0612edd61ce1db4e437aa563c7f6c8aa3287e 100644 --- a/captcha.go +++ b/captcha.go @@ -12,7 +12,7 @@ type respHSiteKey struct { // Route to expose hCaptcha site key. // Returns a constant pre-generated response // to avoid unnecessary allocations or serialisations -func routeHCaptchaSiteKey(app *fiber.App, stub bool, siteKey string) { +func routeHCaptchaSiteKey(app *fiber.App, p string, stub bool, siteKey string) { var resp string if stub { resp = mustConstResp(newMessage(false, "hCaptcha is not enabled on this instance.")) @@ -20,7 +20,7 @@ func routeHCaptchaSiteKey(app *fiber.App, stub bool, siteKey string) { resp = mustConstResp(respHSiteKey{true, siteKey}) } - app.Get("/captcha", func(c fiber.Ctx) error { + app.Get(p, func(c fiber.Ctx) error { c.Set("Content-Type", "application/json; charset=utf-8") return c.SendString(resp) }) diff --git a/register.go b/register.go index acf152599a62d1102a8add2ba90e8358e14a7f98..a27fb2497b8bc310a7adc18e48cc2a7fa4caac14 100644 --- a/register.go +++ b/register.go @@ -15,8 +15,8 @@ type registration struct { } // Waitlist registration route -func routeRegister(app *fiber.App, db *leveldb.DB, captcha fiber.Handler) { - app.Post("/register", func(c fiber.Ctx) error { +func routeRegister(app *fiber.App, p string, db *leveldb.DB, captcha fiber.Handler) { + app.Post(p, func(c fiber.Ctx) error { req := new(registration) // Parse and validate the request