allow passthrow query parameters
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Pilz.Extensions.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Web;
|
||||
|
||||
namespace Pilz.Net.Api;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user