|
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
| 2 | +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
| 3 | + |
| 4 | +using System; |
| 5 | + |
| 6 | +namespace Microsoft.AspNetCore.Http |
| 7 | +{ |
| 8 | + public static class HttpMethod |
| 9 | + { |
| 10 | + public static readonly string Connect = "CONNECT"; |
| 11 | + public static readonly string Delete = "DELETE"; |
| 12 | + public static readonly string Get = "GET"; |
| 13 | + public static readonly string Head = "HEAD"; |
| 14 | + public static readonly string Options = "OPTIONS"; |
| 15 | + public static readonly string Patch = "PATCH"; |
| 16 | + public static readonly string Post = "POST"; |
| 17 | + public static readonly string Put = "PUT"; |
| 18 | + public static readonly string Trace = "TRACE"; |
| 19 | + |
| 20 | + public static bool IsConnect(string method) |
| 21 | + { |
| 22 | + return object.ReferenceEquals(Connect, method) || StringComparer.OrdinalIgnoreCase.Equals(Connect, method); |
| 23 | + } |
| 24 | + |
| 25 | + public static bool IsDelete(string method) |
| 26 | + { |
| 27 | + return object.ReferenceEquals(Delete, method) || StringComparer.OrdinalIgnoreCase.Equals(Delete, method); |
| 28 | + } |
| 29 | + |
| 30 | + public static bool IsGet(string method) |
| 31 | + { |
| 32 | + return object.ReferenceEquals(Get, method) || StringComparer.OrdinalIgnoreCase.Equals(Get, method); |
| 33 | + } |
| 34 | + |
| 35 | + public static bool IsHead(string method) |
| 36 | + { |
| 37 | + return object.ReferenceEquals(Head, method) || StringComparer.OrdinalIgnoreCase.Equals(Head, method); |
| 38 | + } |
| 39 | + |
| 40 | + public static bool IsOptions(string method) |
| 41 | + { |
| 42 | + return object.ReferenceEquals(Options, method) || StringComparer.OrdinalIgnoreCase.Equals(Options, method); |
| 43 | + } |
| 44 | + |
| 45 | + public static bool IsPatch(string method) |
| 46 | + { |
| 47 | + return object.ReferenceEquals(Patch, method) || StringComparer.OrdinalIgnoreCase.Equals(Patch, method); |
| 48 | + } |
| 49 | + |
| 50 | + public static bool IsPost(string method) |
| 51 | + { |
| 52 | + return object.ReferenceEquals(Post, method) || StringComparer.OrdinalIgnoreCase.Equals(Post, method); |
| 53 | + } |
| 54 | + |
| 55 | + public static bool IsPut(string method) |
| 56 | + { |
| 57 | + return object.ReferenceEquals(Put, method) || StringComparer.OrdinalIgnoreCase.Equals(Put, method); |
| 58 | + } |
| 59 | + |
| 60 | + public static bool IsTrace(string method) |
| 61 | + { |
| 62 | + return object.ReferenceEquals(Trace, method) || StringComparer.OrdinalIgnoreCase.Equals(Trace, method); |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments