Turnstile is a service that allows you to protect your web applications from abuse. It is a Cloudflare service that is currently in private beta. You can read more about it here.
go get github.com/9ssi7/turnstile
package main
import (
"context"
"github.com/9ssi7/turnstile"
)
func main() {
ctx := context.Background()
srv := turnstile.New(turnstile.Config{
Secret: "your-secret",
})
ok, err := srv.Verify(ctx, "your-token", "your-ip")
if err != nil {
panic(err)
}
if !ok {
panic("token is not valid")
}
println("token is valid")
}
Contributions are always welcome!