Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5e4cc97ba | ||
|
|
8550d663de | ||
|
|
a6f32c6e43 | ||
|
|
c8e11bb06f |
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace SimApi.Communications
|
||||
{
|
||||
/// <summary>
|
||||
@@ -9,6 +10,15 @@ namespace SimApi.Communications
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态类型单字段请求
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class SimApiOneFieldRequest<T>
|
||||
{
|
||||
public T Data { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 基础分页请求
|
||||
/// </summary>
|
||||
@@ -17,4 +27,4 @@ namespace SimApi.Communications
|
||||
public int Page { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,5 +37,12 @@ namespace SimApi.Helpers
|
||||
|
||||
return strbul.ToString();
|
||||
}
|
||||
|
||||
public static void Log(string message, string type = "Information")
|
||||
{
|
||||
Console.WriteLine($"[ SimApi ][ {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff")} ][ {type} ]");
|
||||
Console.WriteLine(message);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
-5
@@ -125,8 +125,7 @@ namespace SimApi
|
||||
{
|
||||
builder.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor |
|
||||
ForwardedHeaders.XForwardedProto;
|
||||
options.ForwardedHeaders = ForwardedHeaders.All;
|
||||
options.KnownNetworks.Clear();
|
||||
options.KnownProxies.Clear();
|
||||
});
|
||||
@@ -154,15 +153,23 @@ namespace SimApi
|
||||
public static IApplicationBuilder UseSimApi(this IApplicationBuilder builder)
|
||||
{
|
||||
var options = builder.ApplicationServices.GetService<SimApiOptions>();
|
||||
if (options.EnableForwardHeaders)
|
||||
{
|
||||
SimApiUtil.Log("开始配置ForwardedHeaders...");
|
||||
builder.UseForwardedHeaders();
|
||||
}
|
||||
|
||||
if (options.EnableSimApiAuth)
|
||||
{
|
||||
SimApiUtil.Log("开始配置SimApiAuth...");
|
||||
builder.UseMiddleware<SimApiAuthMiddleware>();
|
||||
}
|
||||
|
||||
if (options.EnableSimApiDoc)
|
||||
{
|
||||
SimApiUtil.Log("开始配置SimApiDoc...");
|
||||
var docOptions = options.SimApiDocOptions;
|
||||
return builder.UseSwagger(x => x.RouteTemplate = "/swagger/{documentName}.json").UseSwaggerUI(x =>
|
||||
builder.UseSwagger(x => x.RouteTemplate = "/swagger/{documentName}.json").UseSwaggerUI(x =>
|
||||
{
|
||||
x.DocumentTitle = docOptions.DocumentTitle;
|
||||
foreach (var group in docOptions.ApiGroups)
|
||||
@@ -178,12 +185,20 @@ namespace SimApi
|
||||
|
||||
if (options.EnableSimApiException)
|
||||
{
|
||||
SimApiUtil.Log("开始配置SimApiException...");
|
||||
builder.UseMiddleware<SimApiExceptionMiddleware>();
|
||||
}
|
||||
|
||||
if (options.EnableForwardHeaders)
|
||||
//请求一下检测存储错误
|
||||
if (options.EnableSimApiStorage)
|
||||
{
|
||||
builder.UseForwardedHeaders();
|
||||
SimApiUtil.Log("开始配置SimApiStorage...");
|
||||
builder.ApplicationServices.GetService<SimApiStorage>();
|
||||
}
|
||||
|
||||
if (options.EnableLowerUrl)
|
||||
{
|
||||
SimApiUtil.Log("开始配置使用URL小写...");
|
||||
}
|
||||
|
||||
return builder;
|
||||
|
||||
Reference in New Issue
Block a user