https://github.com/meyskens/go-turnstile
Go library for Cloudflare Turnstile
https://github.com/meyskens/go-turnstile
Last synced: 19 days ago
JSON representation
Go library for Cloudflare Turnstile
- Host: GitHub
- URL: https://github.com/meyskens/go-turnstile
- Owner: meyskens
- License: mit
- Created: 2022-10-09T12:24:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-22T16:02:23.000Z (almost 2 years ago)
- Last Synced: 2025-03-24T09:11:28.772Z (about 1 month ago)
- Language: Go
- Size: 3.91 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudflare Turnstile Go library
This library is a [Turnstile](https://www.cloudflare.com/products/turnstile//) server side library for Go.
It allows to verify challange responses sent to the server.## Usage
The library gives a struct set up to verify the challenges of a given private key set up with `New()`, responses received by the server can be verified with `Verify()`.
```go
import "github.com/meyskens/go-turnstile"func handleRequest(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
tsResponse, _ := r.Form["cf-turnstile-response"]
ts := turnstile.New("")
//Get IP from RemoteAddr
ip, _, err := net.SplitHostPort(r.RemoteAddr)resp, err := ts.Verify(tsResponse[0], ip)
// handle errors please!
if resp.Success {
// captcha OK!
}
}
```