public void ConfigureServices()

in Source/Services/Tailwind.Traders.ImageClassifier.Api/Startup.cs [29:85]


        public void ConfigureServices(IServiceCollection services)
        {

            var imgPath = Configuration["ImagePath"];
            if (string.IsNullOrEmpty(imgPath))
            {
                imgPath = Path.Combine(_contentRoot, "_upload");
            }
            else
            {
                if (!Path.IsPathRooted(imgPath))
                {
                    imgPath = Path.Combine(_contentRoot, imgPath);
                }
            }

            if (!Directory.Exists(imgPath))
            {
                Directory.CreateDirectory(imgPath);
            }

            var scoringSvc = new ImageScoringService(_contentRoot, imgPath);
            scoringSvc.Init();

            services
                .AddSingleton<IImageScoringService>(scoringSvc)
                .AddControllers()
                .SetCompatibilityVersion(CompatibilityVersion.Latest)
                .Services
                .AddHealthChecks(Configuration)
                .AddApplicationInsightsTelemetry(Configuration)
                .AddModulesService(Configuration);

            var appInsightsIK = Configuration["ApplicationInsights:InstrumentationKey"];

            if (!string.IsNullOrEmpty(appInsightsIK))
            {
                services.AddApplicationInsightsTelemetry(appInsightsIK);
            }

            services.AddApiVersioning(options =>
            {
                options.ReportApiVersions = true;
                options.DefaultApiVersion = new ApiVersion(1, 0);
                options.ApiVersionReader = new QueryStringApiVersionReader();
            });

            services.AddSwaggerGen(options =>
            {
                options.DescribeAllEnumsAsStrings();
                options.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title = "Tailwind Traders - Image Classifier API",
                    Version = "v1"
                });
            });
        }