allow passthrow query parameters

This commit is contained in:
2025-05-20 13:54:10 +02:00
parent c7990947dd
commit 033a1c48b5
2 changed files with 6 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
using Pilz.Extensions.Collections;
using System.Collections.Specialized;
using System.Web;
namespace Pilz.Net.Api;

View File

@@ -1,5 +1,6 @@
using Castle.Core.Logging;
using Pilz.Data;
using Pilz.Extensions.Collections;
using Pilz.Extensions.Reflection;
using System.Diagnostics.CodeAnalysis;
using System.Net;
@@ -551,11 +552,13 @@ public class ApiServer : IApiServer
objs.Add(getMessage());
else if (info.ParameterType.IsAssignableTo(typeof(ApiRequestInfo)))
objs.Add(getRequestInfo());
else if (info.ParameterType.IsAssignableTo(typeof(IDictionary<string, string>)))
objs.Add(queryparams.AllKeys.OfType<string>().ToDictionary(n => n, n => HttpUtility.UrlDecode(queryparams.Get(n))));
else if (handler.Parameters.FirstOrDefault(p => p.Name.Equals(info.Name, StringComparison.InvariantCultureIgnoreCase)) is PrivateParameterInfo parameterInfo
&& url.Split('/').ElementAtOrDefault(parameterInfo.Index) is string parameterValue)
objs.Add(Convert.ChangeType(HttpUtility.UrlDecode(parameterValue), info.ParameterType)); // or Uri.UnescapeDataString(); maybe run this line twice?
else if (queryparams.AllKeys.FirstOrDefault(n => n != null && n.Equals(info.Name, StringComparison.InvariantCultureIgnoreCase)) is string querykey)
objs.Add(Convert.ChangeType(HttpUtility.HtmlDecode(queryparams.Get(querykey)), info.ParameterType));
objs.Add(Convert.ChangeType(HttpUtility.UrlDecode(queryparams.Get(querykey)), info.ParameterType));
else
objs.Add(null);
}