reverseproxy

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCacheReverseProxy

func CreateCacheReverseProxy(cache Cache, opts ...Option) (*httputil.ReverseProxy, error)

func ServeCacheReverseProxy

func ServeCacheReverseProxy(keygen RequestCacheKeyFunc, cache Cache, proxy *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request)

Types

type Cache

type Cache interface {
	Exists(ctx context.Context, key string) (bool, error)
	Delete(ctx context.Context, key string) error
	Save(ctx context.Context, key string, header http.Header, reader io.Reader) error
	Load(ctx context.Context, key string) (http.Header, io.Reader, error)
	Header(ctx context.Context, key string) (http.Header, error)
}

type CommonCache

type CommonCache struct {
	// contains filtered or unexported fields
}

func NewByteCache

func NewByteCache(cache cache.ByteCache, storage storage.Storage, setCacheOptions ...cache.Option) *CommonCache

func (*CommonCache) Delete

func (c *CommonCache) Delete(ctx context.Context, key string) error

func (*CommonCache) Exists

func (c *CommonCache) Exists(ctx context.Context, key string) (bool, error)

func (*CommonCache) Header

func (c *CommonCache) Header(ctx context.Context, key string) (http.Header, error)

func (*CommonCache) Load

func (c *CommonCache) Load(ctx context.Context, key string) (http.Header, io.Reader, error)

func (*CommonCache) Save

func (c *CommonCache) Save(ctx context.Context, key string, header http.Header, reader io.Reader) error

type Option

type Option = func(*ProxyConfig)

func WithCacheKeyFunc

func WithCacheKeyFunc(cacheKeyFunc RequestCacheKeyFunc) Option

func WithDirector

func WithDirector(director func(*http.Request)) Option

func WithResponseCacheCheck

func WithResponseCacheCheck(checker ResponseCacheCheckFunc) Option

func WithTargetURL

func WithTargetURL(target *url.URL) Option

type ProxyConfig

type ProxyConfig struct {
	// contains filtered or unexported fields
}

func NewProxyConfig

func NewProxyConfig(opts ...Option) *ProxyConfig

type RequestCacheKeyFunc

type RequestCacheKeyFunc func(*http.Request) string

type ResponseCacheCheckFunc

type ResponseCacheCheckFunc func(*http.Response) bool

Jump to

Keyboard shortcuts

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