package cacheproxy import ( "regexp" "time" ) type UpstreamMatch struct { Match string `yaml:"match"` Replace string `yaml:"replace"` } type Upstream struct { Server string `yaml:"server"` Match UpstreamMatch `yaml:"match"` } func (upstream Upstream) GetPath(orig string) (string, bool, error) { if upstream.Match.Match == "" || upstream.Match.Replace == "" { return orig, true, nil } matcher, err := regexp.Compile(upstream.Match.Match) if err != nil { return "", false, err } return matcher.ReplaceAllString(orig, upstream.Match.Replace), matcher.MatchString(orig), nil } type LocalStorage struct { Path string `yaml:"path"` TemporaryFilePattern string `yaml:"temporary-file-pattern"` } type Accel struct { EnableByHeader string `yaml:"enable-by-header"` ResponseWithHeaders []string `yaml:"response-with-headers"` } type Storage struct { Type string `yaml:"type"` Local *LocalStorage `yaml:"local"` Accel Accel `yaml:"accel"` } type CachePolicyOnPath struct { Match string `yaml:"match"` RefreshAfter string `yaml:"refresh-after"` } type Cache struct { RefreshAfter time.Duration `yaml:"refresh-after"` Policies []CachePolicyOnPath `yaml:"policies"` } type MiscConfig struct { FirstChunkBytes uint64 `yaml:"first-chunk-bytes"` ChunkBytes uint64 `yaml:"chunk-bytes"` } type Config struct { Upstreams []Upstream `yaml:"upstream"` Storage Storage `yaml:"storage"` Cache Cache `yaml:"cache"` Misc MiscConfig `yaml:"misc"` }