configurationtypes

package
v0.0.0-...-fd6c280 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	BasePath   string      `json:"basepath" yaml:"basepath"`
	Debug      APIEndpoint `json:"debug" yaml:"debug"`
	Prometheus APIEndpoint `json:"prometheus" yaml:"prometheus"`
	Souin      APIEndpoint `json:"souin" yaml:"souin"`
	Security   SecurityAPI `json:"security" yaml:"security"`
}

API structure contains all additional endpoints

type APIEndpoint

type APIEndpoint struct {
	BasePath string `json:"basepath" yaml:"basepath"`
	Enable   bool   `json:"enable" yaml:"enable"`
	Security bool   `json:"security" yaml:"security"`
}

APIEndpoint is the minimal structure to define an endpoint

type AbstractConfigurationInterface

type AbstractConfigurationInterface interface {
	GetUrls() map[string]URL
	GetDefaultCache() DefaultCacheInterface
	GetAPI() API
	GetLogLevel() string
	GetLogger() *zap.Logger
	SetLogger(*zap.Logger)
	GetYkeys() map[string]SurrogateKeys
	GetSurrogateKeys() map[string]SurrogateKeys
	GetCacheKeys() map[RegValue]Key
}

AbstractConfigurationInterface interface

type CDN

type CDN struct {
	APIKey    string `json:"api_key,omitempty" yaml:"api_key,omitempty"`
	Dynamic   bool   `json:"dynamic,omitempty" yaml:"dynamic,omitempty"`
	Email     string `json:"email,omitempty" yaml:"email,omitempty"`
	Hostname  string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
	Network   string `json:"network,omitempty" yaml:"network,omitempty"`
	Provider  string `json:"provider,omitempty" yaml:"provider,omitempty"`
	Strategy  string `json:"strategy,omitempty" yaml:"strategy,omitempty"`
	ServiceID string `json:"service_id,omitempty" yaml:"service_id,omitempty"`
	ZoneID    string `json:"zone_id,omitempty" yaml:"zone_id,omitempty"`
}

CDN config

type Cache

type Cache struct {
	Headers []string `json:"headers" yaml:"headers"`
	Port    Port     `json:"port" yaml:"port"`
}

Cache config

type CacheProvider

type CacheProvider struct {
	// URL to connect to the storage system.
	URL string `json:"url" yaml:"url"`
	// Path to the configuration file.
	Path string `json:"path" yaml:"path"`
	// Declare the cache provider directly in the Souin configuration.
	Configuration interface{} `json:"configuration" yaml:"configuration"`
}

CacheProvider config

type DefaultCache

type DefaultCache struct {
	AllowedHTTPVerbs    []string      `json:"allowed_http_verbs" yaml:"allowed_http_verbs"`
	Badger              CacheProvider `json:"badger" yaml:"badger"`
	CDN                 CDN           `json:"cdn" yaml:"cdn"`
	CacheName           string        `json:"cache_name" yaml:"cache_name"`
	Distributed         bool          `json:"distributed" yaml:"distributed"`
	Headers             []string      `json:"headers" yaml:"headers"`
	Key                 Key           `json:"key" yaml:"key"`
	Etcd                CacheProvider `json:"etcd" yaml:"etcd"`
	Nuts                CacheProvider `json:"nuts" yaml:"nuts"`
	Olric               CacheProvider `json:"olric" yaml:"olric"`
	Redis               CacheProvider `json:"redis" yaml:"redis"`
	Port                Port          `json:"port" yaml:"port"`
	Regex               Regex         `json:"regex" yaml:"regex"`
	Stale               Duration      `json:"stale" yaml:"stale"`
	Timeout             Timeout       `json:"timeout" yaml:"timeout"`
	TTL                 Duration      `json:"ttl" yaml:"ttl"`
	DefaultCacheControl string        `json:"default_cache_control" yaml:"default_cache_control"`
}

DefaultCache configuration

func (*DefaultCache) GetAllowedHTTPVerbs

func (d *DefaultCache) GetAllowedHTTPVerbs() []string

GetAllowedHTTPVerbs returns the allowed verbs to cache

func (*DefaultCache) GetBadger

func (d *DefaultCache) GetBadger() CacheProvider

GetBadger returns the Badger configuration

func (*DefaultCache) GetCDN

func (d *DefaultCache) GetCDN() CDN

GetCDN returns the CDN configuration

func (*DefaultCache) GetCacheName

func (d *DefaultCache) GetCacheName() string

GetCacheName returns the cache name to use in the Cache-Status response header

func (*DefaultCache) GetDefaultCacheControl

func (d *DefaultCache) GetDefaultCacheControl() string

GetDefaultCacheControl returns the default Cache-Control response header value when empty

func (*DefaultCache) GetDistributed

func (d *DefaultCache) GetDistributed() bool

GetDistributed returns if it uses Olric or not as provider

func (*DefaultCache) GetEtcd

func (d *DefaultCache) GetEtcd() CacheProvider

GetEtcd returns etcd configuration

func (*DefaultCache) GetHeaders

func (d *DefaultCache) GetHeaders() []string

GetHeaders returns the default headers that should be cached

func (*DefaultCache) GetKey

func (d *DefaultCache) GetKey() Key

GetKey returns the default Key generation strategy

func (*DefaultCache) GetNuts

func (d *DefaultCache) GetNuts() CacheProvider

GetNuts returns nuts configuration

func (*DefaultCache) GetOlric

func (d *DefaultCache) GetOlric() CacheProvider

GetOlric returns olric configuration

func (*DefaultCache) GetRedis

func (d *DefaultCache) GetRedis() CacheProvider

GetRedis returns olric configuration

func (*DefaultCache) GetRegex

func (d *DefaultCache) GetRegex() Regex

GetRegex returns the regex that shouldn't be cached

func (*DefaultCache) GetStale

func (d *DefaultCache) GetStale() time.Duration

GetStale returns the stale duration

func (*DefaultCache) GetTTL

func (d *DefaultCache) GetTTL() time.Duration

GetTTL returns the default TTL

func (*DefaultCache) GetTimeout

func (d *DefaultCache) GetTimeout() Timeout

GetTimeout returns the backend and cache timeouts

type DefaultCacheInterface

type DefaultCacheInterface interface {
	GetAllowedHTTPVerbs() []string
	GetBadger() CacheProvider
	GetCacheName() string
	GetCDN() CDN
	GetDistributed() bool
	GetEtcd() CacheProvider
	GetNuts() CacheProvider
	GetOlric() CacheProvider
	GetRedis() CacheProvider
	GetHeaders() []string
	GetKey() Key
	GetRegex() Regex
	GetStale() time.Duration
	GetTimeout() Timeout
	GetTTL() time.Duration
	GetDefaultCacheControl() string
}

DefaultCacheInterface interface

type Duration

type Duration struct {
	time.Duration
}

Duration is the super object to wrap the duration and be able to parse it from the configuration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON transform the Duration into a time.duration object

func (*Duration) MarshalYAML

func (d *Duration) MarshalYAML() (interface{}, error)

MarshalYAML transform the Duration into a time.duration object

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON parse the time.duration into a Duration object

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(b *yaml.Node) (e error)

UnmarshalYAML parse the time.duration into a Duration object

type Key

type Key struct {
	DisableBody   bool     `json:"disable_body" yaml:"disable_body"`
	DisableHost   bool     `json:"disable_host" yaml:"disable_host"`
	DisableMethod bool     `json:"disable_method" yaml:"disable_method"`
	Hide          bool     `json:"hide" yaml:"hide"`
	Headers       []string `json:"headers" yaml:"headers"`
}

type Port

type Port struct {
	Web string `json:"web" yaml:"web"`
	TLS string `json:"tls" yaml:"tls"`
}

Port config

type RegValue

type RegValue struct {
	*regexp.Regexp
}

RegValue represent a valid regexp as value

func (*RegValue) UnmarshalJSON

func (r *RegValue) UnmarshalJSON(b []byte) error

UnmarshalJSON parse the string configuration into a compiled regexp.

func (*RegValue) UnmarshalYAML

func (r *RegValue) UnmarshalYAML(b *yaml.Node) error

type Regex

type Regex struct {
	// Prevent the from being cached matching the regex
	Exclude string `json:"exclude" yaml:"exclude"`
}

Regex config

type SecurityAPI

type SecurityAPI struct {
	BasePath string `json:"basepath" yaml:"basepath"`
	Enable   bool   `json:"enable" yaml:"enable"`
	Secret   string `json:"secret" yaml:"secret"`
	Users    []User `json:"users" yaml:"users"`
}

SecurityAPI object contains informations related to the endpoints

type SurrogateKeys

type SurrogateKeys struct {
	URL     string            `json:"url" yaml:"url"`
	Headers map[string]string `json:"headers" yaml:"headers"`
}

SurrogateKeys structure define the way surrogate keys are stored

type Timeout

type Timeout struct {
	Backend Duration `json:"backend" yaml:"backend"`
	Cache   Duration `json:"cache" yaml:"cache"`
}

Timeout configuration to handle the cache provider and the reverse-proxy timeout.

type URL

type URL struct {
	TTL                 Duration `json:"ttl" yaml:"ttl"`
	Headers             []string `json:"headers" yaml:"headers"`
	DefaultCacheControl string   `json:"default_cache_control" yaml:"default_cache_control"`
}

URL configuration

type User

type User struct {
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

User is the minimal structure to define a user

Jump to

Keyboard shortcuts

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