-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpMethodResolver.cs
More file actions
43 lines (42 loc) · 1.38 KB
/
HttpMethodResolver.cs
File metadata and controls
43 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Net.Http;
namespace MakeWebRequest
{
/// <summary>
/// Used to resolve string to HttpMethod
/// </summary>
public static class HttpMethodResolver
{
/// <summary>
/// Resolve request verb string into HttpMethod
/// </summary>
/// <param name="requestVerb">verb string</param>
/// <returns>HttpMethod</returns>
/// <exception cref="InvalidOperationException">Unknown HttpMethod Type</exception>
public static HttpMethod Resolve(string requestVerb)
{
switch (requestVerb.ToLower())
{
case "get":
return HttpMethod.Get;
case "post":
return HttpMethod.Post;
case "put":
return HttpMethod.Put;
case "delete":
return HttpMethod.Delete;
case "head":
return HttpMethod.Head;
case "options":
return HttpMethod.Options;
case "patch":
return HttpMethod.Post;
case "trace":
return HttpMethod.Trace;
default:
Console.WriteLine("Unknown HttpMethod type!");
throw new InvalidOperationException("Unknown HttpMethod Type");
}
}
}
}