cloudflare

package
v1.129.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheService

type CacheService interface {
	Purge(ctx context.Context, params cache.CachePurgeParams, opts ...option.RequestOption) (*cache.CachePurgeResponse, error)
}

CacheService defines the interface for Cloudflare cache service operations

type Client

type Client struct {
	CacheService CacheService
	ZoneID       string
	// contains filtered or unexported fields
}

Client is a wrapper around the Cloudflare Go SDK client

func (*Client) GetTimeout added in v1.116.0

func (c *Client) GetTimeout() time.Duration

GetTimeout returns the timeout duration for Cloudflare API requests.

func (*Client) PurgeByPrefixes

func (c *Client) PurgeByPrefixes(ctx context.Context, prefixes []string) error

PurgeByPrefixes purges the Cloudflare cache for the given URL prefixes Prefixes are sent in batches of maxPrefixesPerPurge to comply with Cloudflare API limits

type Clienter

type Clienter interface {
	PurgeByPrefixes(ctx context.Context, prefixes []string) error
	GetTimeout() time.Duration
}

Clienter defines the interface for Cloudflare client operations

func New

func New(cfg *Config) (Clienter, error)

New creates a new Cloudflare client with the provided configuration.

type Config

type Config struct {
	APIToken string        `envconfig:"CLOUDFLARE_API_TOKEN" json:"-"`
	ZoneID   string        `envconfig:"CLOUDFLARE_ZONE_ID"`
	BaseURL  string        `envconfig:"CLOUDFLARE_BASE_URL"`
	Timeout  time.Duration `envconfig:"CLOUDFLARE_TIMEOUT"`
}

Config holds configuration details for Cloudflare API access

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a Config struct with default test values. This is compatible with dis-cloudflare-stub: https://github.com/ONSdigital/dp-compose/tree/main/v2/stubs/dis-cloudflare-stub

func (*Config) Validate added in v1.116.0

func (cfg *Config) Validate() error

Validate checks that all required fields are set in the Config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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