BSD-3-Clause licensed by Sibi Prabakaran
Maintained by [email protected]
This version can be pinned in stack with:wai-slack-middleware-0.1.0.0@sha256:d22bb556df997993175096f589a00f3fe7308a60f4d82e5bc96680ae3a7b20e6,1559

Module documentation for 0.1.0.0

wai-slack-middleware

Build Status

A Slack middleware for wai Used for logging the request information into Slack from a WAI application via middleware.

Usage:

Settings are controlled via the type SlackConfig:

import Network.HTTP.Types.Status
let slackConfig = SlackConfig {
    webHookUrl = "https://hooks.slack.com/services/xxx/xxxxxxxx",
    httpManager = appHttpManager foundation,
    logStatus = \status -> status400 == status
}

The above configuration will send slack notification to all 400 http status code.

Integrating with yesod scaffolding templates

Go to Application.hs and change the function makeApplication to something like this:

makeApplication :: App -> IO Application
makeApplication foundation = do
  logWare <- makeLogWare foundation
  let slackConfig = SlackConfig {
                               webHookUrl = "https://hooks.slack.com/services/xxxx/xxxxxxx",
                               httpManager = appHttpManager foundation,
                               logStatus = \_ -> True
                             }
  -- Create the WAI application and apply middlewares
  appPlain <- toWaiAppPlain foundation
  return $ slack slackConfig $ logWare $ defaultMiddlewaresNoLogging appPlain

Ref: