httpcache

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTerminalResponse = errors.New("httpcache: terminal response written")

ErrTerminalResponse indicates the proxy must not write again: the handler already wrote the full HTTP response (e.g. cache HIT served from plugin.OnRequest).

Functions

func AttachTerminalAwareProxyOnError

func AttachTerminalAwareProxyOnError(cfg *middleware.ProxyConfig)

AttachTerminalAwareProxyOnError wraps cfg.OnError so cache HITs (ErrTerminalResponse) do not get a second write.

func DefaultProxyOnError

func DefaultProxyOnError(err error, rw http.ResponseWriter, req *http.Request)

DefaultProxyOnError mirrors github.com/go-zoox/proxy defaultOnError so we can wrap cfg.OnError and skip writing when ErrTerminalResponse is returned from OnRequest.

func IsTerminalResponse

func IsTerminalResponse(err error) bool

IsTerminalResponse reports whether err signals that the response body was already sent.

Types

type HTTPCachePlugin

type HTTPCachePlugin struct {
	plugin.Plugin
	// contains filtered or unexported fields
}

HTTPCachePlugin caches GET (or configured methods) responses in Application.Cache().

func New

func New() *HTTPCachePlugin

New creates the plugin instance; call Prepare from core.

func (*HTTPCachePlugin) OnRequest

func (h *HTTPCachePlugin) OnRequest(ctx *zoox.Context, req *http.Request) error

OnRequest serves cache HITs before the upstream is contacted.

func (*HTTPCachePlugin) OnResponse

func (h *HTTPCachePlugin) OnResponse(ctx *zoox.Context, res *http.Response) error

OnResponse stores cacheable responses after the upstream returns.

func (*HTTPCachePlugin) Prepare

func (h *HTTPCachePlugin) Prepare(app *zoox.Application, cfg *config.Config) error

Prepare loads config and attaches the gateway cache backend.

Jump to

Keyboard shortcuts

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