diff --git a/FastGithub.HttpServer/IRequestLoggingFeature.cs b/FastGithub.HttpServer/IRequestLoggingFeature.cs
new file mode 100644
index 0000000..6a0a52f
--- /dev/null
+++ b/FastGithub.HttpServer/IRequestLoggingFeature.cs
@@ -0,0 +1,13 @@
+namespace FastGithub.HttpServer
+{
+ ///
+ /// 请求日志特性
+ ///
+ public interface IRequestLoggingFeature
+ {
+ ///
+ /// 是否启用
+ ///
+ bool Enable { get; set; }
+ }
+}
diff --git a/FastGithub.HttpServer/RequestLoggingMilldeware.cs b/FastGithub.HttpServer/RequestLoggingMilldeware.cs
index 955d33a..bdf7311 100644
--- a/FastGithub.HttpServer/RequestLoggingMilldeware.cs
+++ b/FastGithub.HttpServer/RequestLoggingMilldeware.cs
@@ -32,6 +32,8 @@ namespace FastGithub.HttpServer
///
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
+ var feature = new RequestLoggingFeature();
+ context.Features.Set(feature);
var stopwatch = Stopwatch.StartNew();
try
@@ -43,6 +45,11 @@ namespace FastGithub.HttpServer
stopwatch.Stop();
}
+ if (feature.Enable == false)
+ {
+ return;
+ }
+
var request = context.Request;
var response = context.Response;
var message = $"{request.Method} {request.Scheme}://{request.Host}{request.Path} responded {response.StatusCode} in {stopwatch.Elapsed.TotalMilliseconds} ms";
@@ -119,5 +126,10 @@ namespace FastGithub.HttpServer
}
return builder.ToString();
}
+
+ private class RequestLoggingFeature : IRequestLoggingFeature
+ {
+ public bool Enable { get; set; } = true;
+ }
}
}
diff --git a/FastGithub.UI/MainWindow.xaml b/FastGithub.UI/MainWindow.xaml
index 78c4bd7..215f5db 100644
--- a/FastGithub.UI/MainWindow.xaml
+++ b/FastGithub.UI/MainWindow.xaml
@@ -146,7 +146,7 @@
-
+
diff --git a/FastGithub/Startup.cs b/FastGithub/Startup.cs
index 9456bfb..2205630 100644
--- a/FastGithub/Startup.cs
+++ b/FastGithub/Startup.cs
@@ -1,5 +1,6 @@
using FastGithub.Configuration;
using FastGithub.FlowAnalyze;
+using FastGithub.HttpServer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
@@ -70,6 +71,11 @@ namespace FastGithub
{
endpoint.MapGet("/flowRates", context =>
{
+ var feature = context.Features.Get();
+ if (feature != null)
+ {
+ feature.Enable = false;
+ }
var flowRate = context.RequestServices.GetRequiredService().GetFlowRate();
return context.Response.WriteAsJsonAsync(flowRate);
});
diff --git a/FastGithub/wwwroot/flow.html b/FastGithub/wwwroot/flow.html
index 0f77c2a..1716ffb 100644
--- a/FastGithub/wwwroot/flow.html
+++ b/FastGithub/wwwroot/flow.html
@@ -20,7 +20,7 @@
-
+