我有这个要求使用webhook。
我对这个概念很陌生。
我正在努力实现这一点。
https://learn.microsoft.com/en-us/aspnet/webhooks/receiving/receivers
目前我有:
using JahezWebhookAPI.Models;
using Microsoft.AspNet.WebHooks;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
namespace JahezWebhookAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class JahezSalesOrderHandler : ControllerBase, IWebHookHandler
{
public int Order => 1;
public string Receiver => "JAHEZ";
public List<JahezSalesOrder> SalesOrders { get; set; }
[Route("Create")]
[HttpPost]
public Task ExecuteAsync(string receiver, WebHookHandlerContext context)
{
CustomNotifications notifications = context.GetDataOrDefault<CustomNotifications>();
foreach (var notification in notifications.Notifications)
{
foreach(var note in notification)
{
//my logic goes here
}
}
return Task.FromResult(true);
}
}
}
我有两个问题
第一个,我的客户端如何通过WebHookHandlerContext
?
第二,如何从任务结果返回OK?
1条答案
按热度按时间xriantvc1#
这里是chatgpt答案?
使用Web API
和消费者