microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
aacebo/mcp-client

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Common/Http/HttpRequest.cs

68lines · modecode

1namespace Microsoft.Teams.Common.Http;
2
3public interface IHttpRequest : IHttpRequestOptions
4{
5 public HttpMethod Method { get; set; }
6 public string Url { get; set; }
7 public object? Body { get; set; }
8}
9
10public class HttpRequest : HttpRequestOptions, IHttpRequest
11{
12 public required HttpMethod Method { get; set; }
13 public required string Url { get; set; }
14 public object? Body { get; set; }
15
16 public static HttpRequest Get(string url, IHttpRequestOptions? options = null)
17 {
18 return new HttpRequest()
19 {
20 Method = HttpMethod.Get,
21 Url = url,
22 Headers = options?.Headers ?? new Dictionary<string, IList<string>>(),
23 };
24 }
25
26 public static HttpRequest Post(string url, object? body = default, IHttpRequestOptions? options = null)
27 {
28 return new HttpRequest()
29 {
30 Method = HttpMethod.Post,
31 Url = url,
32 Body = body,
33 Headers = options?.Headers ?? new Dictionary<string, IList<string>>(),
34 };
35 }
36
37 public static HttpRequest Patch(string url, object? body = default, IHttpRequestOptions? options = null)
38 {
39 return new HttpRequest()
40 {
41 Method = new HttpMethod("PATCH"),
42 Url = url,
43 Body = body,
44 Headers = options?.Headers ?? new Dictionary<string, IList<string>>(),
45 };
46 }
47
48 public static HttpRequest Put(string url, object? body = default, IHttpRequestOptions? options = null)
49 {
50 return new HttpRequest()
51 {
52 Method = HttpMethod.Put,
53 Url = url,
54 Body = body,
55 Headers = options?.Headers ?? new Dictionary<string, IList<string>>(),
56 };
57 }
58
59 public static HttpRequest Delete(string url, IHttpRequestOptions? options = null)
60 {
61 return new HttpRequest()
62 {
63 Method = HttpMethod.Delete,
64 Url = url,
65 Headers = options?.Headers ?? new Dictionary<string, IList<string>>(),
66 };
67 }
68}