Documentation ¶
Index ¶
- type Configuration
- func (c *Configuration) GetAPI() configurationtypes.API
- func (c *Configuration) GetCacheKeys() configurationtypes.CacheKeys
- func (c *Configuration) GetDefaultCache() configurationtypes.DefaultCacheInterface
- func (c *Configuration) GetLogLevel() string
- func (c *Configuration) GetLogger() core.Logger
- func (c *Configuration) GetPluginName() string
- func (c *Configuration) GetSurrogateKeys() map[string]configurationtypes.SurrogateKeys
- func (c *Configuration) GetUrls() map[string]configurationtypes.URL
- func (c *Configuration) GetYkeys() map[string]configurationtypes.SurrogateKeys
- func (c *Configuration) SetLogger(l core.Logger)
- type DefaultCache
- func (d *DefaultCache) GetAllowedHTTPVerbs() []string
- func (d *DefaultCache) GetBadger() configurationtypes.CacheProvider
- func (d *DefaultCache) GetCDN() configurationtypes.CDN
- func (d *DefaultCache) GetCacheName() string
- func (d *DefaultCache) GetDefaultCacheControl() string
- func (d *DefaultCache) GetDistributed() bool
- func (d *DefaultCache) GetEtcd() configurationtypes.CacheProvider
- func (d *DefaultCache) GetHeaders() []string
- func (d *DefaultCache) GetKey() configurationtypes.Key
- func (d *DefaultCache) GetMaxBodyBytes() uint64
- func (d *DefaultCache) GetMode() string
- func (d *DefaultCache) GetNats() configurationtypes.CacheProvider
- func (d *DefaultCache) GetNuts() configurationtypes.CacheProvider
- func (d *DefaultCache) GetOlric() configurationtypes.CacheProvider
- func (d *DefaultCache) GetOtter() configurationtypes.CacheProvider
- func (d *DefaultCache) GetRedis() configurationtypes.CacheProvider
- func (d *DefaultCache) GetRegex() configurationtypes.Regex
- func (d *DefaultCache) GetStale() time.Duration
- func (d *DefaultCache) GetStorers() []string
- func (d *DefaultCache) GetTTL() time.Duration
- func (d *DefaultCache) GetTimeout() configurationtypes.Timeout
- func (d *DefaultCache) IsCoalescingDisable() bool
- type SouinApp
- type SouinCaddyMiddleware
- func (SouinCaddyMiddleware) CaddyModule() caddy.ModuleInfo
- func (s *SouinCaddyMiddleware) Cleanup() error
- func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error
- func (s *SouinCaddyMiddleware) Provision(ctx caddy.Context) error
- func (s *SouinCaddyMiddleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (s *SouinCaddyMiddleware) UnmarshalCaddyfile(h *caddyfile.Dispenser) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { // Default cache to fallback on when none are redefined. DefaultCache DefaultCache // API endpoints enablers. API configurationtypes.API // Cache keys configuration. CacheKeys configurationtypes.CacheKeys `json:"cache_keys"` // Override the ttl depending the cases. URLs map[string]configurationtypes.URL // Logger level, fallback on caddy's one when not redefined. LogLevel string // SurrogateKeys contains the surrogate keys to use with a predefined mapping SurrogateKeys map[string]configurationtypes.SurrogateKeys // contains filtered or unexported fields }
Configuration holder
func (*Configuration) GetAPI ¶
func (c *Configuration) GetAPI() configurationtypes.API
GetAPI get the default cache
func (*Configuration) GetCacheKeys ¶
func (c *Configuration) GetCacheKeys() configurationtypes.CacheKeys
GetCacheKeys get the cache keys rules to override
func (*Configuration) GetDefaultCache ¶
func (c *Configuration) GetDefaultCache() configurationtypes.DefaultCacheInterface
GetDefaultCache get the default cache
func (*Configuration) GetLogLevel ¶
func (c *Configuration) GetLogLevel() string
GetLogLevel get the log level
func (*Configuration) GetLogger ¶
func (c *Configuration) GetLogger() core.Logger
GetLogger get the logger
func (*Configuration) GetPluginName ¶
func (c *Configuration) GetPluginName() string
GetDefaultCache get the default cache
func (*Configuration) GetSurrogateKeys ¶
func (c *Configuration) GetSurrogateKeys() map[string]configurationtypes.SurrogateKeys
GetSurrogateKeys get the surrogate keys list
func (*Configuration) GetUrls ¶
func (c *Configuration) GetUrls() map[string]configurationtypes.URL
GetUrls get the urls list in the configuration
func (*Configuration) GetYkeys ¶
func (c *Configuration) GetYkeys() map[string]configurationtypes.SurrogateKeys
GetYkeys get the ykeys list
func (*Configuration) SetLogger ¶
func (c *Configuration) SetLogger(l core.Logger)
SetLogger set the logger
type DefaultCache ¶
type DefaultCache struct { // Allowed HTTP verbs to be cached by the system. AllowedHTTPVerbs []string `json:"allowed_http_verbs"` // Badger provider configuration. Badger configurationtypes.CacheProvider `json:"badger"` // The cache name to use in the Cache-Status response header. CacheName string `json:"cache_name"` CDN configurationtypes.CDN `json:"cdn"` // The default Cache-Control header value if none set by the upstream server. DefaultCacheControl string `json:"default_cache_control"` // The maximum body size (in bytes) to be stored into cache. MaxBodyBytes uint64 `json:"max_cacheable_body_bytes"` // Redis provider configuration. Distributed bool `json:"distributed"` // Headers to add to the cache key if they are present. Headers []string `json:"headers"` // Configure the global key generation. Key configurationtypes.Key `json:"key"` // Mode defines if strict or bypass. Mode string `json:"mode"` // Olric provider configuration. Olric configurationtypes.CacheProvider `json:"olric"` // Redis provider configuration. Redis configurationtypes.CacheProvider `json:"redis"` // Etcd provider configuration. Etcd configurationtypes.CacheProvider `json:"etcd"` // Nats provider configuration. Nats configurationtypes.CacheProvider `json:"nats"` // NutsDB provider configuration. Nuts configurationtypes.CacheProvider `json:"nuts"` // Otter provider configuration. Otter configurationtypes.CacheProvider `json:"otter"` // Regex to exclude cache. Regex configurationtypes.Regex `json:"regex"` // Storage providers chaining and order. Storers []string `json:"storers"` // Time before cache or backend access timeout. Timeout configurationtypes.Timeout `json:"timeout"` // Time to live. TTL configurationtypes.Duration `json:"ttl"` // Stale time to live. Stale configurationtypes.Duration `json:"stale"` // Disable the coalescing system. DisableCoalescing bool `json:"disable_coalescing"` }
DefaultCache the struct
func (*DefaultCache) GetAllowedHTTPVerbs ¶
func (d *DefaultCache) GetAllowedHTTPVerbs() []string
GetAllowedHTTPVerbs returns the allowed verbs to cache
func (*DefaultCache) GetBadger ¶
func (d *DefaultCache) GetBadger() configurationtypes.CacheProvider
GetBadger returns the Badger configuration
func (*DefaultCache) GetCDN ¶
func (d *DefaultCache) GetCDN() configurationtypes.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 configured default cache control value
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() configurationtypes.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() configurationtypes.Key
GetKey returns the default Key generation strategy
func (*DefaultCache) GetMaxBodyBytes ¶
func (d *DefaultCache) GetMaxBodyBytes() uint64
GetMaxBodyBytes returns the maximum body size (in bytes) to be cached
func (*DefaultCache) GetMode ¶
func (d *DefaultCache) GetMode() string
GetMode returns mdoe configuration
func (*DefaultCache) GetNats ¶
func (d *DefaultCache) GetNats() configurationtypes.CacheProvider
GetNats returns nuts configuration
func (*DefaultCache) GetNuts ¶
func (d *DefaultCache) GetNuts() configurationtypes.CacheProvider
GetNuts returns nuts configuration
func (*DefaultCache) GetOlric ¶
func (d *DefaultCache) GetOlric() configurationtypes.CacheProvider
GetOlric returns olric configuration
func (*DefaultCache) GetOtter ¶
func (d *DefaultCache) GetOtter() configurationtypes.CacheProvider
GetOtter returns otter configuration
func (*DefaultCache) GetRedis ¶
func (d *DefaultCache) GetRedis() configurationtypes.CacheProvider
GetRedis returns redis configuration
func (*DefaultCache) GetRegex ¶
func (d *DefaultCache) GetRegex() configurationtypes.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) GetStorers ¶
func (d *DefaultCache) GetStorers() []string
GetStorers returns the chianed storers
func (*DefaultCache) GetTTL ¶
func (d *DefaultCache) GetTTL() time.Duration
GetTTL returns the default TTL
func (*DefaultCache) GetTimeout ¶
func (d *DefaultCache) GetTimeout() configurationtypes.Timeout
GetTimeout returns the backend and cache timeouts
func (*DefaultCache) IsCoalescingDisable ¶
func (d *DefaultCache) IsCoalescingDisable() bool
IsCoalescingDisable returns if the coalescing is disabled
type SouinApp ¶
type SouinApp struct { DefaultCache // The provider to use. Storers []types.Storer // Surrogate storage to support th econfiguration reload without surrogate-key data loss. SurrogateStorage providers.SurrogateInterface // Cache-key tweaking. CacheKeys configurationtypes.CacheKeys `json:"cache_keys,omitempty"` // API endpoints enablers. API configurationtypes.API `json:"api,omitempty"` // Logger level, fallback on caddy's one when not redefined. LogLevel string `json:"log_level,omitempty"` }
SouinApp contains the whole Souin necessary items
func (SouinApp) CaddyModule ¶
func (s SouinApp) CaddyModule() caddy.ModuleInfo
CaddyModule implements caddy.ModuleInfo
type SouinCaddyMiddleware ¶
type SouinCaddyMiddleware struct { *middleware.SouinBaseHandler Configuration Configuration // Logger level, fallback on caddy's one when not redefined. LogLevel string `json:"log_level,omitempty"` // Allowed HTTP verbs to be cached by the system. AllowedHTTPVerbs []string `json:"allowed_http_verbs,omitempty"` // Headers to add to the cache key if they are present. Headers []string `json:"headers,omitempty"` // Configure the Badger cache storage. Badger configurationtypes.CacheProvider `json:"badger,omitempty"` // Configure the global key generation. Key configurationtypes.Key `json:"key,omitempty"` // Override the cache key generation matching the pattern. CacheKeys configurationtypes.CacheKeys `json:"cache_keys,omitempty"` // Configure the Nuts cache storage. Nuts configurationtypes.CacheProvider `json:"nuts,omitempty"` // Configure the Otter cache storage. Otter configurationtypes.CacheProvider `json:"otter,omitempty"` // Enable the Etcd distributed cache storage. Etcd configurationtypes.CacheProvider `json:"etcd,omitempty"` // Enable the Redis distributed cache storage. Redis configurationtypes.CacheProvider `json:"redis,omitempty"` // Enable the Olric distributed cache storage. Olric configurationtypes.CacheProvider `json:"olric,omitempty"` // Time to live for a key, using time.duration. Timeout configurationtypes.Timeout `json:"timeout,omitempty"` // Time to live for a key, using time.duration. TTL configurationtypes.Duration `json:"ttl,omitempty"` // Time to live for a stale key, using time.duration. Stale configurationtypes.Duration `json:"stale,omitempty"` // Storage providers chaining and order. Storers []string `json:"storers,omitempty"` // The default Cache-Control header value if none set by the upstream server. DefaultCacheControl string `json:"default_cache_control,omitempty"` // The cache name to use in the Cache-Status response header. CacheName string `json:"cache_name,omitempty"` // contains filtered or unexported fields }
SouinCaddyMiddleware allows the user to set up an HTTP cache system, RFC-7234 compliant and supports the tag based cache purge, distributed and not-distributed storage, key generation tweaking.
func (SouinCaddyMiddleware) CaddyModule ¶
func (SouinCaddyMiddleware) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*SouinCaddyMiddleware) Cleanup ¶
func (s *SouinCaddyMiddleware) Cleanup() error
func (*SouinCaddyMiddleware) FromApp ¶
func (s *SouinCaddyMiddleware) FromApp(app *SouinApp) error
FromApp to initialize configuration from App structure.
func (*SouinCaddyMiddleware) Provision ¶
func (s *SouinCaddyMiddleware) Provision(ctx caddy.Context) error
Provision to do the provisioning part.
func (*SouinCaddyMiddleware) ServeHTTP ¶
func (s *SouinCaddyMiddleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
ServeHTTP implements caddyhttp.MiddlewareHandler.
func (*SouinCaddyMiddleware) UnmarshalCaddyfile ¶
func (s *SouinCaddyMiddleware) UnmarshalCaddyfile(h *caddyfile.Dispenser) error