mirror of https://github.com/dapr/docs.git
[Pub/sub subscriptions] Fix C# example (#2545)
* 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>
This commit is contained in:
parent
f88c853c4e
commit
b00ce0371e
|
|
@ -191,15 +191,25 @@ The programmatic approach returns the `routes` JSON structure within the code, u
|
||||||
{{% codetab %}}
|
{{% codetab %}}
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
[Topic("pubsub", "checkout", event.type ==\"order\"")]
|
[Topic("pubsub", "orders")]
|
||||||
[HttpPost("orders")]
|
[HttpPost("/checkout")]
|
||||||
public async Task<ActionResult<Stock>> HandleCheckout(Checkout checkout, [FromServices] DaprClient daprClient)
|
public async Task<ActionResult<Order>>Checkout(Order order, [FromServices] DaprClient daprClient)
|
||||||
{
|
{
|
||||||
// Logic
|
// 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 %}}
|
||||||
|
|
||||||
{{% codetab %}}
|
{{% codetab %}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue