代码拉取完成,页面将自动刷新
同步操作将从 廖曾波/APIJSON.NET 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
namespace APIJSON.NET
{
using System;
using System.Collections.Generic;
using System.Text;
using APIJSON.NET.Models;
using APIJSON.NET.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using SqlKata.Execution;
using Swashbuckle.AspNetCore.Swagger;
using MySql.Data.MySqlClient;
using SqlKata.Compilers;
public class Startup
{
private const string _defaultCorsPolicyName = "localhost";
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<List<Role>>(Configuration.GetSection("RoleList"));
services.Configure<Dictionary<string,string>>(Configuration.GetSection("tablempper"));
services.Configure<TokenAuthConfiguration>(tokenAuthConfig =>
{
tokenAuthConfig.SecurityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration["Authentication:JwtBearer:SecurityKey"]));
tokenAuthConfig.Issuer = Configuration["Authentication:JwtBearer:Issuer"];
tokenAuthConfig.Audience = Configuration["Authentication:JwtBearer:Audience"];
tokenAuthConfig.SigningCredentials = new SigningCredentials(tokenAuthConfig.SecurityKey, SecurityAlgorithms.HmacSha256);
tokenAuthConfig.Expiration = TimeSpan.FromDays(1);
});
AuthConfigurer.Configure(services, Configuration);
services.AddCors( options => options.AddPolicy( _defaultCorsPolicyName,
builder =>
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod().AllowCredentials()
));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "APIJSON.NET", Version = "v1" });
});
// services.AddSingleton<DbContext>();
//services.AddSingleton<SelectTable>();
services.AddScoped<DbContext>();
services.AddScoped<SelectTable>();
services.AddSingleton<TokenAuthConfiguration>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddTransient<IIdentityService, IdentityService>();
services.AddTransient<ITableMapper, TableMapper>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseStaticFiles();
app.UseCors(_defaultCorsPolicyName);
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.UseJwtTokenMiddleware();
DbInit.Initialize(app);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。