From 0b66b36f4c2efb67fd28e67352a0cb82aff6aeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Michalski?= Date: Wed, 6 Nov 2019 12:36:02 +0100 Subject: [PATCH 1/4] Fixed nested usage for HttpRouter handler --- uhttpsharp/Handlers/HttpRouter.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/uhttpsharp/Handlers/HttpRouter.cs b/uhttpsharp/Handlers/HttpRouter.cs index c6a7394..f24d5a5 100644 --- a/uhttpsharp/Handlers/HttpRouter.cs +++ b/uhttpsharp/Handlers/HttpRouter.cs @@ -26,6 +26,8 @@ public class HttpRouter : IHttpRequestHandler { private readonly IDictionary _handlers = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + private readonly static string StateLevelPropertyName = "HttpRouteLevel"; + public HttpRouter With(string function, IHttpRequestHandler handler) { _handlers.Add(function, handler); @@ -37,9 +39,16 @@ public Task Handle(IHttpContext context, Func nextHandler) { string function = string.Empty; - if (context.Request.RequestParameters.Length > 0) + int index = GetRouteLevel(context.State); + + if (context.Request.RequestParameters.Length > 0 && index < context.Request.RequestParameters.Length) { - function = context.Request.RequestParameters[0]; + function = context.Request.RequestParameters[index]; + if (!string.IsNullOrEmpty(function)) + { + //we are handling this path + IncreaseRouteLevel(context.State); + } } IHttpRequestHandler value; @@ -52,5 +61,19 @@ public Task Handle(IHttpContext context, Func nextHandler) // Route not found, Call next. return nextHandler(); } + + private int GetRouteLevel(dynamic state) + { + if (!((IDictionary)state).ContainsKey(StateLevelPropertyName)) + { + state.HttpRouteLevel = 0; + } + return state.HttpRouteLevel; + } + + private void IncreaseRouteLevel(dynamic state) + { + state.HttpRouteLevel = state.HttpRouteLevel + 1; + } } -} \ No newline at end of file +} From 0eb45741c168c77029088e42fdaa1192fac8dea2 Mon Sep 17 00:00:00 2001 From: Lukasz Michalski Date: Mon, 15 Jun 2020 16:59:23 +0200 Subject: [PATCH 2/4] log4net and json updated --- uhttpsharp-demo/packages.config | 4 ++-- uhttpsharp-demo/uhttpsharp.Demo.csproj | 10 ++++------ uhttpsharp.Tests/packages.config | 2 ++ uhttpsharp.Tests/uhttpsharp.Tests.csproj | 8 ++++++++ uhttpsharp/packages.config | 3 ++- uhttpsharp/uhttpsharp.csproj | 8 +++++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/uhttpsharp-demo/packages.config b/uhttpsharp-demo/packages.config index 639150b..b39b0bc 100644 --- a/uhttpsharp-demo/packages.config +++ b/uhttpsharp-demo/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/uhttpsharp-demo/uhttpsharp.Demo.csproj b/uhttpsharp-demo/uhttpsharp.Demo.csproj index fb380e5..f1d50ef 100644 --- a/uhttpsharp-demo/uhttpsharp.Demo.csproj +++ b/uhttpsharp-demo/uhttpsharp.Demo.csproj @@ -39,13 +39,11 @@ false - - False - ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + ..\..\..\NuGetPackages\log4net.2.0.6\lib\net45-full\log4net.dll - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\..\..\NuGetPackages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll diff --git a/uhttpsharp.Tests/packages.config b/uhttpsharp.Tests/packages.config index 02801fe..913d607 100644 --- a/uhttpsharp.Tests/packages.config +++ b/uhttpsharp.Tests/packages.config @@ -1,5 +1,7 @@  + + diff --git a/uhttpsharp.Tests/uhttpsharp.Tests.csproj b/uhttpsharp.Tests/uhttpsharp.Tests.csproj index 5fa6850..b704faa 100644 --- a/uhttpsharp.Tests/uhttpsharp.Tests.csproj +++ b/uhttpsharp.Tests/uhttpsharp.Tests.csproj @@ -34,6 +34,14 @@ 4 + + ..\..\..\NuGetPackages\log4net.2.0.6\lib\net45-full\log4net.dll + True + + + ..\..\..\NuGetPackages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + True + ..\packages\NSubstitute.1.8.1.0\lib\net45\NSubstitute.dll diff --git a/uhttpsharp/packages.config b/uhttpsharp/packages.config index b7ba33b..6beab21 100644 --- a/uhttpsharp/packages.config +++ b/uhttpsharp/packages.config @@ -1,5 +1,6 @@  - + + \ No newline at end of file diff --git a/uhttpsharp/uhttpsharp.csproj b/uhttpsharp/uhttpsharp.csproj index 424e233..002770c 100644 --- a/uhttpsharp/uhttpsharp.csproj +++ b/uhttpsharp/uhttpsharp.csproj @@ -36,9 +36,11 @@ false - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\..\..\NuGetPackages\log4net.2.0.5\lib\net45-full\log4net.dll + + + ..\..\..\NuGetPackages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll From 2fc036b8417efd7e2766cb67bf0bd0548ce04db8 Mon Sep 17 00:00:00 2001 From: Lukasz Michalski Date: Wed, 3 Mar 2021 14:10:29 +0100 Subject: [PATCH 3/4] Json 8.0 -> 10.0 --- uhttpsharp/packages.config | 3 +-- uhttpsharp/uhttpsharp.csproj | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/uhttpsharp/packages.config b/uhttpsharp/packages.config index 6beab21..8bd2b5b 100644 --- a/uhttpsharp/packages.config +++ b/uhttpsharp/packages.config @@ -1,6 +1,5 @@  - - + \ No newline at end of file diff --git a/uhttpsharp/uhttpsharp.csproj b/uhttpsharp/uhttpsharp.csproj index 002770c..47d82ac 100644 --- a/uhttpsharp/uhttpsharp.csproj +++ b/uhttpsharp/uhttpsharp.csproj @@ -36,11 +36,8 @@ false - - ..\..\..\NuGetPackages\log4net.2.0.5\lib\net45-full\log4net.dll - - - ..\..\..\NuGetPackages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + + ..\..\..\NuGetPackages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll From a925965a5b59330ac2a71d161b37a2382e828540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Michalski?= Date: Wed, 18 Jun 2025 12:34:42 +0200 Subject: [PATCH 4/4] Newtonsoft.Json updated to 13.0.3 --- uhttpsharp/packages.config | 2 +- uhttpsharp/uhttpsharp.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/uhttpsharp/packages.config b/uhttpsharp/packages.config index 8bd2b5b..0b3580f 100644 --- a/uhttpsharp/packages.config +++ b/uhttpsharp/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/uhttpsharp/uhttpsharp.csproj b/uhttpsharp/uhttpsharp.csproj index 47d82ac..b899c23 100644 --- a/uhttpsharp/uhttpsharp.csproj +++ b/uhttpsharp/uhttpsharp.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,7 +10,7 @@ Properties uhttpsharp uhttpsharp - v4.5 + v4.8 512 ..\ @@ -36,8 +36,8 @@ false - - ..\..\..\NuGetPackages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + ..\..\..\NuGetPackages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll