handler

package
v0.0.0-...-f53e655 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CASHandler

type CASHandler struct {
	Local     *repository.LocalRepository
	Client    *http.Client
	Upstreams []string
	AppCtx    context.Context // Application context (from Cobra), not request context
	// contains filtered or unexported fields
}

func NewCASHandler

func NewCASHandler(local *repository.LocalRepository, client *http.Client, upstreams []string, appCtx context.Context) *CASHandler

func (*CASHandler) Serve

func (h *CASHandler) Serve(w http.ResponseWriter, r *http.Request, id utils.Hash, candidateSources []string)

Serve handles the fetch logic for a given hash ID with candidate source URLs. It checks the local cache first, then tries upstreams followed by the candidate sources. candidateSources are also forwarded as X-Source-Urls to upstreams.

func (*CASHandler) ServeHTTP

func (h *CASHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type CASLookupHandler

type CASLookupHandler struct {
	CAS     *CASHandler
	Sources *SourceMap
}

CASLookupHandler serves CAS requests using a pre-populated source map instead of X-Source-Urls headers.

func NewCASLookupHandler

func NewCASLookupHandler(cas *CASHandler, sources *SourceMap) *CASLookupHandler

func (*CASLookupHandler) ServeHTTP

func (h *CASLookupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SourceMap

type SourceMap = utils.ThreadSafeMap[string, []string]

SourceMap maps "algo:hash" to a list of source URLs.

Jump to

Keyboard shortcuts

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