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

Function main

cmd/imageproxy/main.go:57–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func main() {
58 envy.Parse("IMAGEPROXY")
59 flag.Parse()
60
61 p := imageproxy.NewProxy(nil, cache.Cache)
62 if *allowHosts != "" {
63 p.AllowHosts = strings.Split(*allowHosts, ",")
64 }
65 if *denyHosts != "" {
66 p.DenyHosts = strings.Split(*denyHosts, ",")
67 }
68 if *referrers != "" {
69 p.Referrers = strings.Split(*referrers, ",")
70 }
71 if *contentTypes != "" {
72 p.ContentTypes = strings.Split(*contentTypes, ",")
73 }
74 if *passRequestHeaders != "" {
75 p.PassRequestHeaders = strings.Split(*passRequestHeaders, ",")
76 }
77 p.SignatureKeys = signatureKeys
78 if *baseURL != "" {
79 var err error
80 p.DefaultBaseURL, err = url.Parse(*baseURL)
81 if err != nil {
82 log.Fatalf("error parsing baseURL: %v", err)
83 }
84 }
85
86 p.IncludeReferer = *includeReferer
87 p.FollowRedirects = *followRedirects
88 p.Timeout = *timeout
89 p.ScaleUp = *scaleUp
90 p.Verbose = *verbose
91 p.UserAgent = *userAgent
92 p.MinimumCacheDuration = *minCacheDuration
93 p.ForceCache = *forceCache
94
95 server := &http.Server{
96 Addr: *addr,
97 Handler: p,
98
99 ReadTimeout: 10 * time.Second,
100 WriteTimeout: 30 * time.Second,
101 IdleTimeout: 120 * time.Second,
102 }
103
104 fmt.Printf("imageproxy listening on %s\n", server.Addr)
105 log.Fatal(server.ListenAndServe())
106}
107
108type signatureKeyList [][]byte
109

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.92
NewProxyFunction · 0.92

Tested by

no test coverage detected