From d126e500895cf3d26cf0ef7208e2ce62953f049c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Fri, 19 Apr 2024 17:10:39 +0200 Subject: [PATCH] feat: HCaptcha Middleware --- hcaptcha/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hcaptcha/README.md b/hcaptcha/README.md index 5adcaad3..952956e0 100644 --- a/hcaptcha/README.md +++ b/hcaptcha/README.md @@ -4,7 +4,6 @@ id: hcaptcha # HCaptcha - ![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=hcaptcha*) [![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord) ![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg) @@ -33,17 +32,18 @@ go get -u github.com/gofiber/contrib/hcaptcha ``` ## Signature + ```go hcaptcha.New(config hcaptcha.Config) fiber.Handler ``` ## Config -| Property | Type | Description | Default | -|:----------------|:----------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------| -| SecretKey | `string` | The secret key you got from HCaptcha admin panel. This field must not be empty. | `""` | -| ResponseKeyFunc | `func(fiber.Ctx) (string, error)` | ResponseKeyFunc should return the token that captcha provides upon successful solving. By default it gets the token from the body by parsing a JSON request and returns the `hcaptcha_token` field. | `hcaptcha.DefaultResponseKeyFunc` | -| SiteVerifyURL | `string` | It uses this API resource for token authentication. | `https://api.hcaptcha.com/siteverify` | +| Property | Type | Description | Default | +|:----------------|:----------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------| +| SecretKey | `string` | The secret key you obtained from the HCaptcha admin panel. This field must not be empty. | `""` | +| ResponseKeyFunc | `func(fiber.Ctx) (string, error)` | ResponseKeyFunc should return the token that captcha provides upon successful solving. By default, it gets the token from the body by parsing a JSON request and returns the `hcaptcha_token` field. | `hcaptcha.DefaultResponseKeyFunc` | +| SiteVerifyURL | `string` | This property specifies the API resource used for token authentication. | `https://api.hcaptcha.com/siteverify` | ## Example @@ -52,13 +52,13 @@ package main import ( "github.com/gofiber/contrib/hcaptcha" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "log" ) const ( - TestSecretKey = "0x0000000000000000000000000000000000000000" - TestSiteKey = "20000000-ffff-ffff-ffff-000000000002" + TestSecretKey = "0x0000000000000000000000000000000000000000" + TestSiteKey = "20000000-ffff-ffff-ffff-000000000002" ) func main() { @@ -80,4 +80,4 @@ func main() { log.Fatal(app.Listen(":3000")) } -``` \ No newline at end of file +```