Beispiel #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            // uncomment, if you want to add an MVC-based UI
            //services.AddControllersWithViews();

            var appSettingsSection = Configuration.GetSection("AppSettings");

            services.Configure <AppSettings>(appSettingsSection);
            var appSettings = appSettingsSection.Get <AppSettings>();

            services.AddSingleton(Configuration.GetSection("AppSettings").Get <AppSettings>());// * AppSettings


            var RedisUrl  = Environment.GetEnvironmentVariable("RedisUrl") ?? "localhost:7000,defaultDatabase=1,abortConnect=false";
            var IssuerUri = Environment.GetEnvironmentVariable("IssuerUri") ?? "http://*****:*****@lunasoft.co.kr",
                        Url   = new Uri(CompanyUrl),
                    },
                    License = new OpenApiLicense
                    {
                        Name = $"Document",
                        Url  = new Uri(DocUrl),
                    }
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Name         = "Authorization",
                    Type         = SecuritySchemeType.ApiKey,
                    Scheme       = "Bearer",
                    BearerFormat = "JWT",
                    In           = ParameterLocation.Header,
                    Description  = "JWT Authorization header using the Bearer scheme."
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        new string[] {}
                    }
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            //DB¼³Á¤
            services.AddScoped <UserRepository>();

            //Redis ¼³Á¤
            services.AddSingleton <UserRedisRepository>();
            services.AddDistributedRedisCache(option =>
            {
                option.Configuration = RedisUrl;
                option.InstanceName  = "identyuser:";
            });
        }