middleware

package
v0.0.0-...-2ba2e4a Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 31 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upstream50xError = upstream50xError{}

Functions

This section is empty.

Types

type BaseConfiguration

type BaseConfiguration struct {
	DefaultCache  *configurationtypes.DefaultCache  `json:"default_cache" yaml:"default_cache"`
	API           configurationtypes.API            `json:"api" yaml:"api"`
	CacheKeys     configurationtypes.CacheKeys      `json:"cache_keys" yaml:"cache_keys"`
	URLs          map[string]configurationtypes.URL `json:"urls" yaml:"urls"`
	LogLevel      string                            `json:"log_level" yaml:"log_level"`
	Logger        core.Logger
	PluginName    string
	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() core.Logger

GetLogger get the logger

func (*BaseConfiguration) GetPluginName

func (c *BaseConfiguration) GetPluginName() string

GetPluginName get the plugin name

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 core.Logger)

SetLogger set the logger

type CustomWriter

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

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

func NewCustomWriter

func NewCustomWriter(rq *http.Request, rw http.ResponseWriter, b *bytes.Buffer) *CustomWriter

func (*CustomWriter) GetStatusCode

func (r *CustomWriter) GetStatusCode() int

GetStatusCode returns the response status code

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 SouinBaseHandler

type SouinBaseHandler struct {
	Configuration            configurationtypes.AbstractConfigurationInterface
	Storers                  []types.Storer
	InternalEndpointHandlers *api.MapHandler
	ExcludeRegex             *regexp.Regexp
	RegexpUrls               regexp.Regexp
	SurrogateKeys            configurationtypes.SurrogateKeys
	SurrogateKeyStorer       providers.SurrogateInterface
	DefaultMatchedUrl        configurationtypes.URL
	// contains filtered or unexported fields
}

func (*SouinBaseHandler) HandleInternally

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

func (*SouinBaseHandler) Revalidate

func (s *SouinBaseHandler) Revalidate(validator *core.Revalidator, next handlerFunc, customWriter *CustomWriter, rq *http.Request, requestCc *cacheobject.RequestCacheDirectives, cachedKey string, uri string) error

func (*SouinBaseHandler) ServeHTTP

func (s *SouinBaseHandler) ServeHTTP(rw http.ResponseWriter, rq *http.Request, next handlerFunc) error

func (*SouinBaseHandler) Store

func (s *SouinBaseHandler) Store(
	customWriter *CustomWriter,
	rq *http.Request,
	requestCc *cacheobject.RequestCacheDirectives,
	cachedKey string,
	uri string,
) error

func (*SouinBaseHandler) Upstream

func (s *SouinBaseHandler) Upstream(
	customWriter *CustomWriter,
	rq *http.Request,
	next handlerFunc,
	requestCc *cacheobject.RequestCacheDirectives,
	cachedKey string,
	uri string,
) error

type SouinWriterInterface

type SouinWriterInterface interface {
	http.ResponseWriter
	Send() (int, error)
}

Jump to

Keyboard shortcuts

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