Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddCors();

            // Configure Redis Connection
            var options = new ConfigurationOptions
            {
                EndPoints = { "redis-12388.c261.us-east-1-4.ec2.cloud.redislabs.com:12388" },
                Password = "******",
                AllowAdmin = true,
                AbortOnConnectFail = false,
            };
            services.AddSingleton<IConnectionMultiplexer>(
               ConnectionMultiplexer.Connect(options));

            // Register KeyService
            services.AddScoped<IKeysService, KeysService>();

            services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

            // Configure Swagger
            services.AddSwaggerGen(options => {
                options.SwaggerDoc("KonnectAPI",
                    new Microsoft.OpenApi.Models.OpenApiInfo()
                    {
                        Title = "Konnect - Redis Cache - API",
                        Version = "1",
                        Description = "API Documentation by Konnect Dev Team"
                    });
                options.IncludeXmlComments("KONNECT-REDIS.xml");
            });
        }