Add RestType enum and extension methods for HTTP verbs
Introduced RestType enum in ReC.Domain.Constants to represent HTTP methods, including support for None and Invalid values. Added RestTypeExtensions with ToHttpMethod and IsValid methods to facilitate HTTP method handling and validation.
This commit is contained in:
29
src/ReC.Domain/Constants/RestType.cs
Normal file
29
src/ReC.Domain/Constants/RestType.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
namespace ReC.Domain.Constants;
|
||||||
|
|
||||||
|
public enum RestType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Get = 1,
|
||||||
|
Post = 2,
|
||||||
|
Put = 3,
|
||||||
|
Patch = 4,
|
||||||
|
Delete = 5,
|
||||||
|
Head = 6,
|
||||||
|
Options = 7,
|
||||||
|
Connect = 8,
|
||||||
|
Trace = 9,
|
||||||
|
Invalid = -1,
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RestTypeExtensions
|
||||||
|
{
|
||||||
|
public static string ToHttpMethod(this RestType restType)
|
||||||
|
{
|
||||||
|
return restType.ToString().ToUpper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsValid(this RestType restType)
|
||||||
|
{
|
||||||
|
return restType != RestType.Invalid && restType != RestType.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user