Skip to content

Commit

Permalink
[Pub/sub subscriptions] Fix C# example (#2545)
Browse files Browse the repository at this point in the history
* fix csharp example per hal

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

* update per Mark

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

* add second example

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

Co-authored-by: Mark Fussell <markfussell@gmail.com>
  • Loading branch information
hhunter-ms and msfussell committed Jun 24, 2022
1 parent f88c853 commit b00ce03
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,25 @@ The programmatic approach returns the `routes` JSON structure within the code, u
{{% codetab %}}

```csharp
[Topic("pubsub", "checkout", event.type ==\"order\"")]
[HttpPost("orders")]
public async Task<ActionResult<Stock>> HandleCheckout(Checkout checkout, [FromServices] DaprClient daprClient)
[Topic("pubsub", "orders")]
[HttpPost("/checkout")]
public async Task<ActionResult<Order>>Checkout(Order order, [FromServices] DaprClient daprClient)
{
// Logic
return stock;
return order;
}
```

or

```csharp
// Dapr subscription in [Topic] routes orders topic to this route
app.MapPost("/checkout", [Topic("pubsub", "orders")] (Order order) => {
Console.WriteLine("Subscriber received : " + order);
return Results.Ok(order);
});
```

{{% /codetab %}}

{{% codetab %}}
Expand Down

0 comments on commit b00ce03

Please sign in to comment.