# BoomSlackNotifier

Provides a Slack notifier for the [BoomNotifier]( exception notification package.

You can read the full documentation at [](

## Installation

The package can be installed by adding `boom_slack_notifier` to your list of dependencies in

def deps do
    {:boom_notifier, "~> 0.8.0"},
    {:boom_slack_notifier, "~> 0.1.0"}

## How to use it

defmodule YourApp.Router do
  use Phoenix.Router

  use BoomNotifier,
    notifier: BoomSlackNotifier.SlackNotifier,
    options: [
      webhook_url: "<your-slack-generated-url>",

  # ...

To configure it, you need to set the `webhook_url` in the `options` keyword list. A `POST` request with a `json` will be made to that webhook when an error ocurrs with the relevant information.

### Setting up a Slack webhook

If you don't already have a webhook setup for Slack, you can follow the steps below:

1. Go to [Slack API]( > My Apps
2. Create a new application
3. Inside your new application go to > Add features and functionality > Incoming Webhooks
4. Activate incoming webhooks for your application
5. Scroll down to 'Webhook URLs for Your Workspace' and create a new Webhook URL for a given channel.

## Http client

By default BoomSlackNotifier uses [HTTPoison]( as the http client. 

You can setup your favorite client by warpping it with the `SlackAdapter` behaviour, for example:


  @impl BoomSlackNotifier.SlackAdapter
  @spec post(any, binary, any) :: {:ok, any} | {:error, any}
  def post(body, url, headers) do
    {:ok, response} = Mojito.request(body: body, method: :post, url: url, headers: headers)
    # ...

And then specifying it in your application configuration:


config :boom_slack_notifier, :slack_adapter, MyApp.MojitoHttpAdapter


Default configuration (not required): 
config :boom_slack_notifier, :slack_adapter, BoomSlackNotifier.SlackClient.HTTPoisonAdapter
## License

BoomSlackNotifier is released under the terms of the [MIT License](