dispatch:emissary-transport-webhook

v0.11.1Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Webhook Transport

Hit an arbitrary endpoint as a notification

Setup

Add the package as a dependency of another package:

1api.use(['dispatch:emissary-transport-webhook'], 'server');

Or just use it in your root application:

$ meteor add dispatch:emissary-transport-webhook

Usage

Configuration/Working the Queue

In this package, the configuration for the HTTP request itself is stored on the job. So there is no configuration for the transport.

1var transport = new WebhookTransport();
2
3transport.register();

Queuing Messages

The HTTP request configuration is defined when you run Emissary.queueTask.

1Emissary.queueTask('webhook', {
2  bodyTemplate:'<arbitrary handlebars template for request body>',
3  templateData:{<data to fill in bodyTemplate with>},
4  transportConfig:{
5    headers:{
6      'Content-Type':'text/plain',
7      'Some Other Header':'some value'
8    },
9    url:'https://mydomain.com/webhook',
10    method:'POST',
11    basicAuth:'username:password',
12    expectStatus:200
13  }
14});

Parameters

  • headers - optional dictionary of request headers
  • url - full URL of the endpoint
  • method - HTTP method ("GET", "POST", "PUT", "DELETE", or "PATCH")
  • basicAuth - optional credentials for HTTP basic auth. Format with ':'
  • expectStatus - if this is provided, the request will be considered a failure if the response status code does not equal this value. Otherwise, it will be considered a failure if it is not a 200-level status code'