summary refs log tree commit diff
path: root/ModAS.Server/Extensions/RequestHeaderExtensinos.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2023-12-31 12:00:40 +0100
committerRory& <root@rory.gay>2023-12-31 12:00:40 +0100
commitc5b72e6f002a637d542068be88d70936150c8818 (patch)
treec7d7a5c99329e88bce47b60b566b8398c0dd4a68 /ModAS.Server/Extensions/RequestHeaderExtensinos.cs
parentRoom query (diff)
downloadModAS-c5b72e6f002a637d542068be88d70936150c8818.tar.xz
Add auth, start of commit script
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