Fiber reCAPTCHA Plugin
Fiber reCAPTCHA Middleware, Auto detect, verify and abort reCAPTCHA request
Installation
go get github.com/codenoid/fiber-recaptcha
Usage
package main
import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()
secret := "6LenMekbAAAAAIUbHoSiOmf1CkhECk75AcKUysRF"
captcha, err := fiberrecaptcha.InitRecaptchaV3(secret, 10*time.Second)
if err != nil {
panic(err)
}
captcha.ErrResponse = func(c *fiber.Ctx) error {
if val, ok := c.Locals("recaptcha_error").(string); ok {
return c.SendString(fmt.Sprint("captcha error: ", val))
}
return nil
}
// YOU MUST EXPLICITLY DEFINE captcha.UseCaptcha before real handler
app.Get("/", captcha.UseCaptcha, func(c *fiber.Ctx) error {
return c.SendString("Hello, World 👋!")
})
app.Listen(":3000")
}