Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/ExampleProject/HttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public void WithJsonContent<T>(T body, Action<JsonSerializerOptions>? configureS
Content = new StringContent(JsonSerializer.Serialize(body));
}

[FluentMethod(3)]
public void WithoutContent()
{
}

[FluentMethod(4)]
[FluentReturn]
public HttpRequestMessage GetMessage()
Expand All @@ -42,4 +47,12 @@ public HttpRequestMessage GetMessage()
Headers.ForEach(h => request.Headers.Add(h.Item1, h.Item2));
return request;
}

[FluentMethod(4)]
[FluentReturn]
public async Task<HttpResponseMessage> SendAsync(HttpClient client)
{
HttpRequestMessage request = GetMessage();
return await client.SendAsync(request);
}
}
14 changes: 14 additions & 0 deletions src/ExampleProject/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@

Console.WriteLine(JsonSerializer.Serialize(message));

// await RunAsyncExample();
static async Task RunAsyncExample()

Check warning on line 126 in src/ExampleProject/Program.cs

View workflow job for this annotation

GitHub Actions / build

The local function 'RunAsyncExample' is declared but never used

Check warning on line 126 in src/ExampleProject/Program.cs

View workflow job for this annotation

GitHub Actions / build

The local function 'RunAsyncExample' is declared but never used
{
HttpClient client = new HttpClient();
HttpResponseMessage response = await CreateHttpRequest
.WithMethod(HttpMethod.Get)
.WithUrl("https://www.m31coding.com")
.WithZeroHeaders()
.WithoutContent()
.SendAsync(client);

Console.WriteLine(response.StatusCode);
}

// Node
//

Expand Down
Loading