turnstile

package
v0.0.0-...-f0a2dc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Secret is the secret key used to verify the token.
	// This is required.
	Secret string

	// Timeout is the timeout for the service.
	// This is optional.
	// Default: 10 seconds
	Timeout time.Duration
}

Config is the configuration for the service.

type Service

type Service interface {
	// Verify is used to verify the token.
	// It returns true if the token is valid.
	// It returns false if the token is invalid.
	// It returns an error if there was an error verifying the token.
	Verify(ctx context.Context, token string, ip string) (bool, error)

	// VerifyIdempotent is used to verify the token.
	// The key parameter is used to ensure idempotency.
	// You may use the RandomUUID method to generate a random UUID.
	// It returns true if the token is valid.
	// It returns false if the token is invalid.
	// It returns an error if there was an error verifying the token.
	VerifyIdempotent(ctx context.Context, token string, ip string, key string) (bool, error)

	// RandomUUID is used to generate a random UUID.
	// It returns a random UUID.
	RandomUUID() string
}

Service is the interface for the service. It is used to verify the token. It is also used to generate a random UUID.

func New

func New(config Config) Service

New is used to create a new service. It returns a new service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL