cachecontrol

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Make

func Make(ctx context.Context, options ...MakeOption)

func New

func New() transports.Middleware

func NewWithCache

func NewWithCache(cache Cache) transports.Middleware

Types

type Cache

type Cache interface {
	Get(ctx context.Context, key []byte) (value []byte, has bool, err error)
	Set(ctx context.Context, key []byte, value []byte, ttl time.Duration) (err error)
	Close()
}

type Config

type Config struct {
	Enable bool `json:"enable"`
	MaxAge int  `json:"maxAge"`
}

type DefaultCache

type DefaultCache struct{}

func (*DefaultCache) Close

func (cache *DefaultCache) Close()

func (*DefaultCache) Get

func (cache *DefaultCache) Get(ctx context.Context, key []byte) (value []byte, has bool, err error)

func (*DefaultCache) Set

func (cache *DefaultCache) Set(ctx context.Context, key []byte, value []byte, ttl time.Duration) (err error)

type MakeOption

type MakeOption func(option *MakeOptions)

func MaxAge

func MaxAge(age int) MakeOption

func MustRevalidate

func MustRevalidate() MakeOption

func Private

func Private() MakeOption

func ProxyRevalidate

func ProxyRevalidate() MakeOption

func Public

func Public() MakeOption

type MakeOptions

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

type Middleware

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

Middleware use @cache-control max-age=10 public=true must-revalidate=false proxy-revalidate=false

func (*Middleware) Close

func (middleware *Middleware) Close() (err error)

func (*Middleware) Construct

func (middleware *Middleware) Construct(options transports.MiddlewareOptions) (err error)

func (*Middleware) Handler

func (middleware *Middleware) Handler(next transports.Handler) transports.Handler

func (*Middleware) Name

func (middleware *Middleware) Name() string

Jump to

Keyboard shortcuts

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