New creates a new imgproxy instance.
(ctx context.Context, config *Config)
| 60 | |
| 61 | // New creates a new imgproxy instance. |
| 62 | func New(ctx context.Context, config *Config) (*Imgproxy, error) { |
| 63 | if err := config.Validate(); err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | |
| 67 | monitoring, err := monitoring.New(ctx, &config.Monitoring, config.Workers.WorkersNumber) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | |
| 72 | errorReporter, err := errorreport.New(&config.ErrorReport) |
| 73 | if err != nil { |
| 74 | return nil, err |
| 75 | } |
| 76 | |
| 77 | securityChecker, err := security.New(&config.Security) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | |
| 82 | fetcher, err := fetcher.New(&config.Fetcher) |
| 83 | if err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | |
| 87 | idf := imagedata.NewFactory(fetcher, monitoring) |
| 88 | |
| 89 | clientFeaturesDetector := clientfeatures.NewDetector(&config.ClientFeatures) |
| 90 | |
| 91 | fallbackImage, err := auximageprovider.NewStaticProvider(ctx, &config.FallbackImage, "fallback", idf) |
| 92 | if err != nil { |
| 93 | return nil, err |
| 94 | } |
| 95 | |
| 96 | watermarkImage, err := auximageprovider.NewStaticProvider(ctx, &config.WatermarkImage, "watermark", idf) |
| 97 | if err != nil { |
| 98 | return nil, err |
| 99 | } |
| 100 | |
| 101 | workers, err := workers.New(&config.Workers) |
| 102 | if err != nil { |
| 103 | return nil, err |
| 104 | } |
| 105 | |
| 106 | processor, err := processing.New(&config.Processing, securityChecker, watermarkImage) |
| 107 | if err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | |
| 111 | optionsParser, err := optionsparser.New(ctx, &config.OptionsParser) |
| 112 | if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | |
| 116 | cookies, err := cookies.New(&config.Cookies) |
| 117 | if err != nil { |
| 118 | return nil, err |
| 119 | } |
nothing calls this directly
no test coverage detected