summary refs log tree commit diff
path: root/ModAS.Server/Extensions/RequestHeaderExtensinos.cs
blob: e40ed8e250268331d8cbf0dca2233ca022f55f53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using Microsoft.AspNetCore.Http.Headers;

namespace MxApiExtensions.Extensions;

public static class RequestHeaderExtensions {
    public static bool TryGet<T>(this RequestHeaders headers, string name, out T? value) {
        try {
            value = headers.Get<T>(name);
            return true;
        }
        catch (Exception) {
            value = default;
        }

        return false;
    }
}