caddy

package module
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: AGPL-3.0 Imports: 20 Imported by: 4

Documentation

Overview

Package caddy provides a handler for Caddy Server (https://caddyserver.com/) allowing to transform any Caddy instance into a Mercure hub.

Index

Constants

This section is empty.

Variables

View Source
var (
	SubscriptionsContextKey = subscriptionsKeyType{} //nolint:gochecknoglobals
	WriteTimeoutContextKey  = writeTimeoutKeyType{}  //nolint:gochecknoglobals
)
View Source
var (
	ErrCompatibility = errors.New("compatibility mode only supports protocol version 7")
)
View Source
var TransportUsagePool = caddy.NewUsagePool() //nolint:gochecknoglobals

Functions

This section is empty.

Types

type Bolt added in v0.17.0

type Bolt struct {
	Path             string  `json:"path,omitempty"`
	BucketName       string  `json:"bucket_name,omitempty"`
	Size             uint64  `json:"size,omitempty"`
	CleanupFrequency float64 `json:"cleanup_frequency,omitempty"`
	// contains filtered or unexported fields
}

func (Bolt) CaddyModule added in v0.17.0

func (Bolt) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Bolt) Cleanup added in v0.17.0

func (b *Bolt) Cleanup() error

func (*Bolt) GetTransport added in v0.17.0

func (b *Bolt) GetTransport() mercure.Transport

func (*Bolt) Provision added in v0.17.0

func (b *Bolt) Provision(ctx caddy.Context) error

Provision provisions b's configuration.

func (*Bolt) UnmarshalCaddyfile added in v0.17.0

func (b *Bolt) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the handler from Caddyfile tokens.

type JWTConfig

type JWTConfig struct {
	Key string `json:"key,omitempty"`
	Alg string `json:"alg,omitempty"`
}

type Local added in v0.17.0

type Local struct {
	// contains filtered or unexported fields
}

func (Local) CaddyModule added in v0.17.0

func (Local) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Local) Cleanup added in v0.17.0

func (l *Local) Cleanup() error

func (*Local) GetTransport added in v0.17.0

func (l *Local) GetTransport() mercure.Transport

func (*Local) Provision added in v0.17.0

func (l *Local) Provision(_ caddy.Context) error

Provision provisions l's configuration.

func (*Local) UnmarshalCaddyfile added in v0.17.0

func (l *Local) UnmarshalCaddyfile(_ *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the handler from Caddyfile tokens.

type Mercure

type Mercure struct {
	// Allow subscribers with no valid JWT.
	Anonymous bool `json:"anonymous,omitempty"`

	// Dispatch updates when subscriptions are created or terminated
	Subscriptions bool `json:"subscriptions,omitempty"`

	// Enable the demo.
	Demo bool `json:"demo,omitempty"`

	// Enable the UI.
	UI bool `json:"ui,omitempty"`

	// Maximum duration before closing the connection, defaults to 600s, set to 0 to disable.
	WriteTimeout *caddy.Duration `json:"write_timeout,omitempty"`

	// Maximum dispatch duration of an update, defaults to 5s.
	DispatchTimeout *caddy.Duration `json:"dispatch_timeout,omitempty"`

	// Frequency of the heartbeat, defaults to 40s.
	Heartbeat *caddy.Duration `json:"heartbeat,omitempty"`

	// JWT key and signing algorithm to use for publishers.
	PublisherJWT JWTConfig `json:"publisher_jwt,omitempty"`

	// JWK Set URL to use for publishers.
	PublisherJWKSURL string `json:"publisher_jwks_url,omitempty"`

	// JWT key and signing algorithm to use for subscribers.
	SubscriberJWT JWTConfig `json:"subscriber_jwt,omitempty"`

	// JWK Set URL to use for subscribers.
	SubscriberJWKSURL string `json:"subscriber_jwks_url,omitempty"`

	// Origins allowed to publish updates
	PublishOrigins []string `json:"publish_origins,omitempty"`

	// Allowed CORS origins.
	CORSOrigins []string `json:"cors_origins,omitempty"`

	// Transport to use.
	//
	// Deprecated: use transports Caddy modules.
	TransportURL string `json:"transport_url,omitempty"`

	// Triggers use of LRU topic selector cache and avoidance of select priority queue (recommend 10,000 - 1,000,000)
	LRUShardSize *int64 `json:"lru_shard_size,omitempty"`

	// The name of the authorization cookie. Defaults to "mercureAuthorization".
	CookieName string `json:"cookie_name,omitempty"`

	// The version of the Mercure protocol to be backward compatible with (only version 7 is supported)
	ProtocolVersionCompatibility int `json:"protocol_version_compatibility,omitempty"`

	// The transport configuration.
	TransportRaw json.RawMessage `json:"transport,omitempty" caddy:"namespace=http.handlers.mercure inline_key=name"` //nolint:tagalign
	// contains filtered or unexported fields
}

Mercure implements a Mercure hub as a Caddy module. Mercure is a protocol allowing to push data updates to web browsers and other HTTP clients in a convenient, fast, reliable and battery-efficient way.

func (Mercure) CaddyModule

func (Mercure) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Mercure) Cleanup deprecated

func (m *Mercure) Cleanup() error

Deprecated: use transports Caddy modules.

func (*Mercure) Provision

func (m *Mercure) Provision(ctx caddy.Context) error

func (Mercure) ServeHTTP

func (m Mercure) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*Mercure) UnmarshalCaddyfile

func (m *Mercure) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the handler from Caddyfile tokens.

type Transport added in v0.17.0

type Transport interface {
	GetTransport() mercure.Transport
}

type TransportDestructor added in v0.17.0

type TransportDestructor[T mercure.Transport] struct {
	Transport T
}

func (TransportDestructor[T]) Destruct added in v0.17.0

func (d TransportDestructor[T]) Destruct() error

Directories

Path Synopsis
Copied from https://github.com/caddyserver/xcaddy/blob/b7fd102f41e12be4735dc77b0391823989812ce8/environment.go#L251
Copied from https://github.com/caddyserver/xcaddy/blob/b7fd102f41e12be4735dc77b0391823989812ce8/environment.go#L251

Jump to

Keyboard shortcuts

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