# GhWebhookPlug

This Plug makes it easy to listen to Github webhook requests in your Elixir
apps and trigger actions.


* Configurable HTTP endpoint
* Verifies authenticity using webhook secret
* Responses are handled for you - just write business logic

## Installation

  1. Add gh_webhook_plug to your list of dependencies in `mix.exs`:

        def deps do
          [{:gh_webhook_plug, "~> 0.0.1"}]

  2. Ensure gh_webhook_plug is started before your application:

        def application do
          [applications: [:gh_webhook_plug]]

## Usage

defmodule DemoPlugApp do
  use Plug.Builder

  # Use GhWebhookPlug and pass it 3 things:
  # 1. secret : the secret you configured when you set up the Github webhook
  # 2. path : The HTTP endpoint which should listen for webhook requests
  # 3. action: Tuple containing the module and function which should handle the webhook payload
  plug GhWebhookPlug, secret: "secret", path: "/gh-webhook", action: {__MODULE__, :gh_webhook}

  # You can add other plugs as you normally would.
  # The connection reaches this plug if the webhook's path is not matched above.
  plug :next_in_chain

  def gh_webhook(payload) do
    # Do something with payload


* Add polymorphic handlers for different types of GH events which are overridable by user.

## License