-
Notifications
You must be signed in to change notification settings - Fork 7
Raising
Jezz Santos edited this page Mar 28, 2017
·
7 revisions
To raise events from your own services:
Install-Package ServiceStack.Webhooks
- Add the
WebhookFeature
to your AppHost (see Getting Started) - Add the
IWebhooks
dependency to any of your services - Call:
IWebhooks.Publish<TDto>(string eventName, TDto data)
.
It is as simple as this:
internal class HelloService : Service
{
public IWebhooks Webhooks { get; set; }
public HelloResponse Any(Hello request)
{
Webhooks.Publish("hello", new HelloEvent{ Text = "I said hello" });
}
}
The data
that you publish with the eventName
can be any POCO/DTO or none.
In this case, an event like the following would be sent to a subscriber:
POST http://asubscriber/hello HTTP/1.1
Accept: application/json
User-Agent: ServiceStack .NET Client 4.56
Accept-Encoding: gzip,deflate
X-Webhook-Delivery: 7a6224aad9c8400fb0a70b8a71262400
X-Webhook-Event: hello
Content-Type: application/json
Host: asubscriber
Content-Length: 26
Expect: 100-continue
Proxy-Connection: Keep-Alive
{
"Text": "I said hello"
}