1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package imagedata
- import (
- "net/http"
- "github.com/imgproxy/imgproxy/v3/ierrors"
- "github.com/imgproxy/imgproxy/v3/imagefetcher"
- "github.com/imgproxy/imgproxy/v3/transport"
- )
- var (
- Fetcher *imagefetcher.Fetcher
- // For tests. This needs to move to fetcher once we will have a way to isolate
- // the fetcher in tests.
- redirectAllRequestsTo string
- )
- type DownloadOptions struct {
- Header http.Header
- CookieJar http.CookieJar
- }
- func initDownloading() error {
- ts, err := transport.NewTransport()
- if err != nil {
- return err
- }
- Fetcher, err = imagefetcher.NewFetcher(ts, imagefetcher.NewConfigFromEnv())
- if err != nil {
- return ierrors.Wrap(err, 0, ierrors.WithPrefix("can't create image fetcher"))
- }
- return nil
- }
- func RedirectAllRequestsTo(u string) {
- redirectAllRequestsTo = u
- }
- func StopRedirectingRequests() {
- redirectAllRequestsTo = ""
- }
|