Skip to content

cpursley/webhoox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhoox

Webhoox makes it easy to deal with inbound webhooks by using an adapter-based approach, saving you time.

This library started off as a fork of Maarten's awesome receivex email-focused library.

Webhoox aims to support the Standard Webhooks spec and includes an authentication module and adapter

Adapters

You can implement your own adapter by following the existing adapters as an example. Pull requests for new adapters welcome!

Installation

Available in Hex, the package can be installed by adding webhoox to your list of dependencies in mix.exs:

def deps do
  [
    {:webhoox, "~> 0.3.0"}
  ]
end

Configuration

Example configuration for Standard Webhook with the Plug router:

# Your router.ex file
forward("_incoming", to: Webhoox, init_opts: [
  adapter: Webhoox.Adapter.StandardWebhook,
  adapter_opts: [secret: "MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"],
  handler: Example.Processor]
)

Example Processor:

  defmodule Example.Processor do
    @behaviour Webhoox.Handler

    def process(webhook = %Webhoox.Webhook.StandardWebhook{}) do
      # You probably want to handle processing of the event asynchronously
      # and go ahead and return a 200 as not to block the sending server
      
      {:ok, "200 OK"}
    end
  end

Documentation can be found at https://hex.pm/packages/webhoox.