update:docker compose 更新
queries构造函数修改 配置json更新
This commit is contained in:
@@ -22,6 +22,7 @@ using QRCodeService.Application.Behaviors;
|
||||
using QRCodeService.Application.Commands;
|
||||
using QRCodeService.Application.Queries;
|
||||
using QRCodeService.Application.Validations;
|
||||
using QRCodeService.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -48,6 +49,9 @@ namespace QRCodeService
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "QRCodeService", Version = "v1" });
|
||||
});
|
||||
//配置
|
||||
services.Configure<ServiceOption>(Configuration.GetSection("hosting"));
|
||||
|
||||
//validator
|
||||
services.AddTransient<IValidator<CreateLinkCommand>, CreateLinkCommandValidator>();
|
||||
|
||||
@@ -60,7 +64,7 @@ namespace QRCodeService
|
||||
services.AddDbContext<AppDbContext>(
|
||||
dbContextOptions => dbContextOptions
|
||||
.UseMySql(
|
||||
"server=localhost;user=root;password=root;database=qrcode",
|
||||
Configuration.GetConnectionString("Default"),
|
||||
// For common usages, see pull request #1233.
|
||||
new MariaDbServerVersion(new Version(10, 5, 9)), // use MariaDbServerVersion for MariaDB
|
||||
mySqlOptions => mySqlOptions
|
||||
@@ -74,8 +78,8 @@ namespace QRCodeService
|
||||
services.AddScoped<IAppRepository, AppRepository>();
|
||||
services.AddScoped<ILinkRepository, LinkRepository>();
|
||||
//Queries
|
||||
services.AddScoped<ILinkQueries, LinkQueries>();
|
||||
services.AddScoped<IAppQueries, AppQueries>();
|
||||
services.AddScoped<ILinkQueries, LinkQueries>( s=>new LinkQueries(Configuration.GetConnectionString("Default")));
|
||||
services.AddScoped<IAppQueries, AppQueries>(s => new AppQueries(Configuration.GetConnectionString("Default")));
|
||||
//redis cache
|
||||
services.AddDistributedRedisCache(options=>options.Configuration=Configuration.GetSection("redis:default").Value);
|
||||
|
||||
@@ -88,7 +92,7 @@ namespace QRCodeService
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ServiceOption option)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
@@ -96,7 +100,10 @@ namespace QRCodeService
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "QRCodeService v1"));
|
||||
}
|
||||
app.UseForwardedHeaders();
|
||||
if (option.IsForwarded)
|
||||
{
|
||||
app.UseForwardedHeaders();
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user