summary refs log tree commit diff
path: root/ModAS.Server/Extensions/RequestHeaderExtensinos.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ModAS.Server/Extensions/RequestHeaderExtensinos.cs')
-rw-r--r--ModAS.Server/Extensions/RequestHeaderExtensinos.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/ModAS.Server/Extensions/RequestHeaderExtensinos.cs b/ModAS.Server/Extensions/RequestHeaderExtensinos.cs
new file mode 100644
index 0000000..e40ed8e
--- /dev/null
+++ b/ModAS.Server/Extensions/RequestHeaderExtensinos.cs
@@ -0,0 +1,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;
+    }
+}
\ No newline at end of file