diff --git a/src/http/partials/Server/HTTP.MiddlewareDescriptor.cs b/src/http/partials/Server/HTTP.MiddlewareDescriptor.cs index 77d4df83..e0e8d0cb 100644 --- a/src/http/partials/Server/HTTP.MiddlewareDescriptor.cs +++ b/src/http/partials/Server/HTTP.MiddlewareDescriptor.cs @@ -12,13 +12,12 @@ internal class MiddlewareDescriptor : IHTTP.MiddlewareDescriptor public string Path { get; } public MiddlewareDescriptor Next { get; set; } - public Action - Callback { get; internal set; } + public Action Callback { get; } public bool UseParams { get; } - public MiddlewareDescriptor(string path, bool useParams, - Action callback) + public MiddlewareDescriptor + (string path, bool useParams, Action callback) { Path = path; UseParams = useParams; @@ -28,8 +27,7 @@ public MiddlewareDescriptor(string path, bool useParams, public void Execute(IHTTP.ServerRequest request, IHTTP.ServerResponse response) { - if (Next == null) return; - Next?.Callback(request, response, () => Next?.Execute(request, response)); + if (Next != null) Next.Callback(request, response, () => Next?.Execute(request, response)); } } } diff --git a/src/http/partials/Server/HTTP.ServerTo.cs b/src/http/partials/Server/HTTP.ServerTo.cs index 1de97b5b..997f065d 100644 --- a/src/http/partials/Server/HTTP.ServerTo.cs +++ b/src/http/partials/Server/HTTP.ServerTo.cs @@ -250,8 +250,8 @@ private async Task HandleConnection(HttpListenerContext context) } } - descriptors[0].Callback(request, response, - () => descriptors[0].Next.Execute(request, response)); + var mainDescriptor = descriptors[0]; + mainDescriptor.Callback(request, response, () => mainDescriptor.Execute(request, response)); } }