httpcache

package
v0.0.0-...-1405280 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CategoryContext

func CategoryContext(ctx context.Context, category string) context.Context

func Purge

func Purge(path string, categories ...string) error

Purge purges the specified categories from the cache.

func WithCategory

func WithCategory(r *http.Request, category string) *http.Request

Types

type Redactor

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

func (*Redactor) Redact

func (x *Redactor) Redact(r *http.Request) *http.Request

func (*Redactor) RedactRequestHeader

func (r *Redactor) RedactRequestHeader(name string, hashed int)

RedactRequestHeader redacts headers with the specified name, optionally with the specified number of hashed characters.

func (*Redactor) RedactRequestURLParam

func (r *Redactor) RedactRequestURLParam(name string, hashed int)

RedactRequestURLParam redacts URL parameters with the specified case-sensitive name, optionally with the specified number of hashed characters.

func (*Redactor) RedactResponse

func (x *Redactor) RedactResponse(r *http.Response) *http.Response

type RequestRedactor

type RequestRedactor interface {
	Redact(req *http.Request) *http.Request
}

RequestRedactor returns a redacted copy of a request. If fields are modified, they must be copied.

type ResponseRedactor

type ResponseRedactor interface {
	RedactResponse(r *http.Response) *http.Response
}

ResponseRedactor redacts a response in-place.

type Transport

type Transport struct {
	// Path is the path to store cached requests at.
	Path string

	// Fallback allows pages from any category to be used.
	Fallback bool

	// RequestRedactor redacts requests for storage.
	RequestRedactor RequestRedactor

	// ResponseRedactor redacts responses.
	ResponseRedactor ResponseRedactor

	// Next is the transport to use for making requests. If nil, only cached
	// responses are used.
	Next http.RoundTripper
}

Transport caches HTTP responses indefinitely based on a URL and an optional category. It supports redacting sensitive headers/parameters.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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