Open levatax opened 1 month ago
The changes introduce a new property, ValidateFunc
, to the hcaptcha
middleware, allowing users to implement custom validation logic upon HCaptcha verification. This function receives a boolean indicating validation success and the Fiber context, returning an error if validation fails. Additionally, the example usage in the README.md
has been updated to reflect these changes, including a new endpoint for submitting requests. The errors
package is now imported to facilitate error handling within the custom validation function.
File | Change Summary |
---|---|
hcaptcha/README.md | Updated documentation to include ValidateFunc , modified example to use /api/submit , and added error handling. |
hcaptcha/config.go | Added ValidateFunc field to Config struct for custom validation logic. |
hcaptcha/hcaptcha.go | Introduced optional ValidateFunc for custom validation in middleware, maintaining original behavior if not provided. |
In the garden where bunnies play,
New validations hop in today!
WithValidateFunc
, oh what a thrill,
Custom checks bring joy and skill.
HCaptcha's now a friend so true,
Let’s celebrate with a joyful “Woohoo!” 🐰✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@levatax thanks for the work can you add any more tests ?
do the other fiber middlewares or other hcaptcha golang functions already have such functions ? just want to make sure that the existing fiber/golang users are satisfied with the function names and functionality and do not expect other schemes can you do some more research?
This pull request introduces custom error handling functionality to the hCaptcha middleware. It allows users to define a custom validation response function, providing greater flexibility for handling hCaptcha validation errors. If the custom function is set, it will be invoked with the validation result, allowing for tailored error responses.
Additionally, this PR corrects the documentation, specifying the correct order of middleware usage. The hCaptcha middleware should be placed before the handler in the route definition, ensuring proper validation of the hCaptcha token before processing requests.
Changes Made:
Summary by CodeRabbit
New Features
ValidateFunc
, allowing users to define their own validation logic for HCaptcha results./api/submit
.Bug Fixes