Documentation ¶
Index ¶
- func Setup(c *caddy.Controller) error
- type CacheRule
- type Config
- type HTTPCache
- type HTTPCacheEntry
- type Handler
- type HeaderCacheRule
- type PathCacheRule
- type Response
- func (rw *Response) Clean() error
- func (rw *Response) Close() error
- func (rw *Response) CloseNotify() <-chan bool
- func (rw *Response) Flush()
- func (rw *Response) Header() http.Header
- func (rw *Response) SetBody(body storage.ResponseStorage)
- func (rw *Response) WaitBody()
- func (rw *Response) WaitClose()
- func (rw *Response) WaitHeaders()
- func (rw *Response) Write(buf []byte) (int, error)
- func (rw *Response) WriteHeader(code int)
- type URLLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CacheRule ¶
type CacheRule interface {
// contains filtered or unexported methods
}
CacheRule determines if a request should be cached
type HTTPCache ¶
type HTTPCache struct {
// contains filtered or unexported fields
}
func NewHTTPCache ¶
type HTTPCacheEntry ¶
type HTTPCacheEntry struct { Request *http.Request Response *Response // contains filtered or unexported fields }
HTTPCacheEntry saves the request response of an http request
func NewHTTPCacheEntry ¶
func NewHTTPCacheEntry(key string, request *http.Request, response *Response, config *Config) *HTTPCacheEntry
NewHTTPCacheEntry creates a new HTTPCacheEntry for the given request and response and it also calculates if the response is public
func (*HTTPCacheEntry) Clean ¶
func (e *HTTPCacheEntry) Clean() error
Clean removes the response if it has an associated file
func (*HTTPCacheEntry) Fresh ¶
func (e *HTTPCacheEntry) Fresh() bool
Fresh returns if the entry is still fresh
func (*HTTPCacheEntry) Key ¶
func (e *HTTPCacheEntry) Key() string
func (*HTTPCacheEntry) WriteBodyTo ¶
func (e *HTTPCacheEntry) WriteBodyTo(w http.ResponseWriter) error
WriteBodyTo sends the body to the http.ResponseWritter
type Handler ¶
type Handler struct { // Handler configuration Config *Config // Cache is where entries are stored Cache *HTTPCache // Next handler Next httpserver.Handler // Handles locking for different URLs URLLocks *URLLock }
Handler is the main cache middleware
func NewHandler ¶
func NewHandler(Next httpserver.Handler, config *Config) *Handler
NewHandler creates a new Handler using Next middleware
type HeaderCacheRule ¶
HeaderCacheRule matches if given Header matches any of the values
type PathCacheRule ¶
type PathCacheRule struct {
Path string
}
PathCacheRule matches if the request starts with given Path
type Response ¶
type Response struct { Code int // the HTTP response code from WriteHeader HeaderMap http.Header // the HTTP response headers // contains filtered or unexported fields }
func (*Response) Close ¶
Close means there won't be any more Writes It closes body if it was set before It should be called after SetBody using WaitBody() Otherwise body won't be closed blocking the response
func (*Response) SetBody ¶
func (rw *Response) SetBody(body storage.ResponseStorage)
func (*Response) WaitHeaders ¶
func (rw *Response) WaitHeaders()
WaitHeaders blocks until headers are sent
func (*Response) Write ¶
Write is the io.Writer interface with the modification required To wait the body. This will wait until SetBody is called with The desired storage.