plugins

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanHandle

CanHandle detect if the request can be handled by Souin

func DefaultSouinPluginCallback

func DefaultSouinPluginCallback(
	res http.ResponseWriter,
	req *http.Request,
	retriever types.RetrieverResponsePropertiesInterface,
	rc coalescing.RequestCoalescingInterface,
	nextMiddleware func(w http.ResponseWriter, r *http.Request) error,
) (e error)

DefaultSouinPluginCallback is the default callback for plugins

func DefaultSouinPluginInitializerFromConfiguration

func DefaultSouinPluginInitializerFromConfiguration(c configurationtypes.AbstractConfigurationInterface) *types.RetrieverResponseProperties

DefaultSouinPluginInitializerFromConfiguration is the default initialization for plugins

func HasMutation

func HasMutation(req *http.Request, rw http.ResponseWriter) bool

Types

type BaseConfiguration

type BaseConfiguration struct {
	DefaultCache  *configurationtypes.DefaultCache                       `json:"default_cache" yaml:"default_cache"`
	API           configurationtypes.API                                 `json:"api" yaml:"api"`
	CacheKeys     map[configurationtypes.RegValue]configurationtypes.Key `yaml:"cache_keys"`
	URLs          map[string]configurationtypes.URL                      `json:"urls" yaml:"urls"`
	LogLevel      string                                                 `json:"log_level" yaml:"log_level"`
	Logger        *zap.Logger
	Ykeys         map[string]configurationtypes.SurrogateKeys `json:"ykeys" yaml:"ykeys"`
	SurrogateKeys map[string]configurationtypes.SurrogateKeys `json:"surrogate_keys" yaml:"surrogate_keys"`
}

BaseConfiguration holder

func (*BaseConfiguration) GetAPI

GetAPI get the default cache

func (*BaseConfiguration) GetCacheKeys

GetCacheKeys get the cache keys rules to override

func (*BaseConfiguration) GetDefaultCache

GetDefaultCache get the default cache

func (*BaseConfiguration) GetLogLevel

func (c *BaseConfiguration) GetLogLevel() string

GetLogLevel get the log level

func (*BaseConfiguration) GetLogger

func (c *BaseConfiguration) GetLogger() *zap.Logger

GetLogger get the logger

func (*BaseConfiguration) GetSurrogateKeys

func (c *BaseConfiguration) GetSurrogateKeys() map[string]configurationtypes.SurrogateKeys

GetSurrogateKeys get the surrogate keys list

func (*BaseConfiguration) GetUrls

GetUrls get the urls list in the configuration

func (*BaseConfiguration) GetYkeys

GetYkeys get the ykeys list

func (*BaseConfiguration) SetLogger

func (c *BaseConfiguration) SetLogger(l *zap.Logger)

SetLogger set the logger

type CustomWriter

type CustomWriter struct {
	Response *http.Response
	Buf      *bytes.Buffer
	Rw       http.ResponseWriter
	Req      *http.Request
	// contains filtered or unexported fields
}

CustomWriter handles the response and provide the way to cache the value

func (*CustomWriter) Header

func (r *CustomWriter) Header() http.Header

Header will write the response headers

func (*CustomWriter) Send

func (r *CustomWriter) Send() (int, error)

Send delays the response to handle Cache-Status

func (*CustomWriter) Write

func (r *CustomWriter) Write(b []byte) (int, error)

Write will write the response body

func (*CustomWriter) WriteHeader

func (r *CustomWriter) WriteHeader(code int)

WriteHeader will write the response headers

type SouinBasePlugin

type SouinBasePlugin struct {
	Retriever         types.RetrieverResponsePropertiesInterface
	RequestCoalescing coalescing.RequestCoalescingInterface
	MapHandler        *api.MapHandler
}

SouinBasePlugin declaration.

func (*SouinBasePlugin) HandleInternally

func (s *SouinBasePlugin) HandleInternally(r *http.Request) (bool, http.HandlerFunc)

HandleInternally handles the Souin custom endpoints

Directories

Path Synopsis
caddy module

Jump to

Keyboard shortcuts

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