fix eventserver bug

This commit is contained in:
2024-07-26 19:18:59 +08:00
parent 1d474f596a
commit 1ee8d941e9
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -224,11 +224,11 @@ public static class SimApiExtensions
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IApplicationBuilder UseSimApi(this IApplicationBuilder builder)
public static WebApplication UseSimApi(this WebApplication builder)
{
var options = builder.ApplicationServices.GetRequiredService<SimApiOptions>();
var options = builder.Services.GetRequiredService<SimApiOptions>();
var logger = builder.ApplicationServices.GetRequiredService<ILogger<SimApiOptions>>();
var logger = builder.Services.GetRequiredService<ILogger<SimApiOptions>>();
logger.LogInformation("当前时区: {LocalId}", TimeZoneInfo.Local.Id);
if (options.EnableForwardHeaders)
@@ -277,7 +277,7 @@ public static class SimApiExtensions
if (options.EnableSimApiStorage)
{
logger.LogInformation("开始配置SimApiStorage...");
builder.ApplicationServices.GetService<SimApiStorage>();
builder.Services.GetService<SimApiStorage>();
}
if (options.EnableLowerUrl)
@@ -287,7 +287,7 @@ public static class SimApiExtensions
if (options.EnableSynapse)
{
var synapse = builder.ApplicationServices.GetRequiredService<Synapse>();
var synapse = builder.Services.GetRequiredService<Synapse>();
synapse.Init();
}
+2 -2
View File
@@ -33,7 +33,7 @@ public partial class Synapse
{
if (mt!.GetParameters().Length == 2)
{
var pt = mt!.GetParameters()[0].ParameterType;
var pt = mt.GetParameters()[1].ParameterType;
mt.Invoke(callClass, pt == typeof(string)
? [eventName, reqBody]
: [eventName, JsonSerializer.Deserialize(reqBody, pt, SimApiUtil.JsonOption)]);
@@ -45,7 +45,7 @@ public partial class Synapse
}
catch (Exception ex)
{
logger.LogError("Synapse Event Processor Error: {Err}", ex.InnerException);
logger.LogError("Synapse Event Processor Error: {Err}\n{Stack}", ex.Message,ex.StackTrace);
}
}