endpoint implementation ...

This commit is contained in:
2026-11-19 18:08:53 +03:30
parent be47468e35
commit bc66d86ed2
7 changed files with 408 additions and 86 deletions
+56
View File
@@ -0,0 +1,56 @@
using System.Text;
namespace xApi.Extensions
{
public static class HttpExtensions
{
/// <summary>
/// Apply Query String to Specified Url ...
/// </summary>
/// <param name="url"></param>
/// <param name="queries"></param>
/// <returns></returns>
public static string ApplyQueryString(
this string url,
IDictionary<string, string>? queries = null
)
{
//
var result = url;
if (queries is null ||
string.IsNullOrWhiteSpace(result))
{
return result;
}
//
// Handling ...
bool isMarkupAdded = false;
var sb = new StringBuilder();
sb.Append(result);
foreach (var param in queries)
{
//
if (string.IsNullOrWhiteSpace(param.Value))
{
continue;
}
//
sb.Append(isMarkupAdded ? '&' : '?');
sb.Append(param.Key);
sb.Append('=');
sb.Append(param.Value);
//
isMarkupAdded = true;
}
//
result = sb.ToString();
//
return result;
}
}
}