public static IServiceCollection ConfigureServices(this IServiceCollection serviceCollection, IConfiguration configuration)
        {
            IQueueConfiguration queueConfig = RabbitMqDefaultConfigLoader.SetDefaults(new RabbitMqQueueConfiguration());

            configuration.Bind(queueConfig);
            serviceCollection.AddSingleton <IQueueConfiguration>(queueConfig);

            IStoreConfiguration storeConfig = AdaptationStoreConfigLoader.SetDefaults(new AdaptationStoreConfiguration());

            configuration.Bind(storeConfig);
            serviceCollection.AddSingleton <IStoreConfiguration>(storeConfig);

            IProcessingConfiguration processingConfig = IcapProcessingConfigLoader.SetDefaults(new IcapProcessingConfiguration());

            configuration.Bind(processingConfig);
            serviceCollection.AddSingleton <IProcessingConfiguration>(processingConfig);

            IVersionConfiguration versionConfiguration = VersionConfigLoader.SetDefaults(new VersionConfiguration());

            configuration.Bind(versionConfiguration);
            serviceCollection.AddSingleton <IVersionConfiguration>(versionConfiguration);

            serviceCollection.AddTransient(typeof(IAdaptationServiceClient <>), typeof(RabbitMqClient <>));
            serviceCollection.AddTransient <IResponseProcessor, AdaptationOutcomeProcessor>();

            return(serviceCollection);
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseCors(Constants.CORS_POLICY);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, Constants.STATIC_FILES_FOLDER_Name)),
            });
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.yaml", "Cloud SDK Api");
                c.InjectJavascript("/Swg/func.js");
                c.InjectJavascript("/Swg/toast/toastify.js");
                c.InjectStylesheet("/Swg/toast/toastify.css");
            });
            app.UseRouting();
            app.UseAuthorization();
            app.Use((context, next) =>
            {
                ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
                {
                    builder.AddConsole();
                });
                ILogger logger = loggerFactory.CreateLogger <Startup>();
                UserAgentInfo userAgentInfo = new UserAgentInfo(context.Request.Headers[Constants.UserAgent.USER_AGENT]);
                logger.LogInformation($"UserAgent:: [{userAgentInfo?.ClientInfo?.String}]");
                IVersionConfiguration versionConfig = app.ApplicationServices.GetService <IVersionConfiguration>();
                context.Response.Headers[Constants.Header.ACCESS_CONTROL_EXPOSE_HEADERS] = Constants.STAR;
                context.Response.Headers[Constants.Header.ACCESS_CONTROL_ALLOW_HEADERS]  = Constants.STAR;
                context.Response.Headers[Constants.Header.ACCESS_CONTROL_ALLOW_ORIGIN]   = Constants.STAR;
                context.Response.Headers[Constants.Header.VIA] = Environment.MachineName;
                context.Response.Headers[Constants.Header.SDK_ENGINE_VERSION] = versionConfig.SDKEngineVersion;
                context.Response.Headers[Constants.Header.SDK_API_VERSION]    = versionConfig.SDKApiVersion;
                return(next.Invoke());
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Ejemplo n.º 3
0
 public DetailController(ILogger <DetailController> logger, IVersionConfiguration versionConfiguration) : base(logger)
 {
     _versionConfiguration = versionConfiguration ?? throw new ArgumentNullException(nameof(versionConfiguration));
 }
Ejemplo n.º 4
0
 public static IVersionConfiguration SetDefaults(IVersionConfiguration configuration)
 {
     configuration.SDKEngineVersion = Constants.Header.SDK_ENGINE_VERSION_VALUE;
     configuration.SDKApiVersion    = Constants.Header.SDK_API_VERSION_VALUE;
     return(configuration);
 }