Skip to content

Commit ee9d91a

Browse files
committed
chore: Tweaks to the sample HttpSend code
In particular, this now generates a random event ID - v1.x used to do this automatically, but in 2.x it needs to be explicit. Signed-off-by: Jon Skeet <[email protected]>
1 parent e517ee4 commit ee9d91a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

samples/HttpSend/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ namespace HttpSend
1919
// line and calling the application code. The [Option] attributes designate the parameters.
2020
class Program
2121
{
22-
[Option(Description = "CloudEvents 'source' (default: urn:example-com:mysource:abc)", LongName = "source",
23-
ShortName = "s")]
22+
[Option(Description = "CloudEvents 'source' (default: urn:example-com:mysource:abc)", LongName = "source", ShortName = "s")]
2423
private string Source { get; } = "urn:example-com:mysource:abc";
2524

2625
[Option(Description = "CloudEvents 'type' (default: com.example.myevent)", LongName = "type", ShortName = "t")]
@@ -35,6 +34,7 @@ private async Task OnExecuteAsync()
3534
{
3635
var cloudEvent = new CloudEvent
3736
{
37+
Id = Guid.NewGuid().ToString(),
3838
Type = Type,
3939
Source = new Uri(Source),
4040
DataContentType = MediaTypeNames.Application.Json,
@@ -44,10 +44,10 @@ private async Task OnExecuteAsync()
4444
var content = cloudEvent.ToHttpContent(ContentMode.Structured, new JsonEventFormatter());
4545

4646
var httpClient = new HttpClient();
47-
// your application remains in charge of adding any further headers or
47+
// Your application remains in charge of adding any further headers or
4848
// other information required to authenticate/authorize or otherwise
4949
// dispatch the call at the server.
50-
var result = (await httpClient.PostAsync(this.Url, content));
50+
var result = await httpClient.PostAsync(Url, content);
5151

5252
Console.WriteLine(result.StatusCode);
5353
}

0 commit comments

Comments
 (0)