MCPcopy
hub / github.com/willnorris/imageproxy / Provision

Method Provision

caddy/module.go:56–75  ·  view source on GitHub ↗
(ctx caddy.Context)

Source from the content-addressed store, hash-verified

54}
55
56func (p *ImageProxy) Provision(ctx caddy.Context) error {
57 p.logger = ctx.Logger()
58 cache, _ := parseCache(p.Cache)
59 p.proxy = imageproxy.NewProxy(nil, cache)
60 p.proxy.DefaultBaseURL, _ = url.Parse(p.DefaultBaseURL)
61 p.proxy.AllowHosts = p.AllowHosts
62 p.proxy.DenyHosts = p.DenyHosts
63 p.proxy.Referrers = p.Referrers
64 p.proxy.ContentTypes = p.ContentTypes
65 if len(p.proxy.ContentTypes) == 0 {
66 p.proxy.ContentTypes = []string{"image/*"}
67 }
68 for _, key := range p.SignatureKeys {
69 p.proxy.SignatureKeys = append(p.proxy.SignatureKeys, []byte(key))
70 }
71 p.proxy.Logger = zap.NewStdLog(p.logger)
72 p.proxy.Verbose = p.Verbose
73 p.proxy.FollowRedirects = true
74 return nil
75}
76
77func (p *ImageProxy) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhttp.Handler) error {
78 p.proxy.ServeHTTP(w, r)

Callers

nothing calls this directly

Calls 2

NewProxyFunction · 0.92
parseCacheFunction · 0.70

Tested by

no test coverage detected