You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
796 B
28 lines
796 B
|
|
using Microsoft.Extensions.Primitives;
|
|
|
|
namespace DealerSelection.Common.Logging;
|
|
|
|
public class HttpHeaderHelper
|
|
{
|
|
public static int? ExtractInt(string key, List<KeyValuePair<string, StringValues>> headers)
|
|
{
|
|
int? res = null;
|
|
string? resString = Extract(key, headers);
|
|
if (resString == null)
|
|
{
|
|
if(int.TryParse(resString, out int resTemp))
|
|
res = resTemp;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
public static string? Extract(string key, List<KeyValuePair<string, StringValues>> headers)
|
|
{
|
|
string? res = null;
|
|
KeyValuePair<string, StringValues> header = headers.FirstOrDefault(h=> h.Key == key);
|
|
if (header.Value.Any())
|
|
res = header.Value.FirstOrDefault();
|
|
return res;
|
|
}
|
|
}
|