wai-slack-middleware: A Slack middleware for WAI

[ bsd3, library, web ] [ Propose Tags ]

Logs the request information into Slack through webhook from a WAI application.


[Skip to Readme]
Versions 0.1.0.0, 0.2.0
Change log CHANGELOG.md
Dependencies aeson, base (>=4.7 && <5), http-client, http-types, wai [details]
License BSD-3-Clause
Copyright Copyright: (c) 2017 Sibi
Author Sibi Prabakaran
Maintainer sibi@psibi.in
Category Web
Home page https://github.com/psibi/wai-slack-middleware#readme
Source repo head: git clone https://github.com/psibi/wai-slack-middleware
Uploaded by psibi at Sat May 6 01:03:06 UTC 2017
Distributions LTSHaskell:0.2.0, NixOS:0.2.0
Downloads 541 total (19 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-06 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for wai-slack-middleware-0.2.0

[back to package description]

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,
    responseFilter = \resp -> status400 == responseStatus resp,
    requestFilter = \_ -> True
}

The above configuration will send slack notification for 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,
                               responseFilter = \resp -> status400 == responseStatus resp,
                               requestFilter = \_ -> True
                             }
  -- Create the WAI application and apply middlewares
  appPlain <- toWaiAppPlain foundation
  return $ slack slackConfig $ logWare $ defaultMiddlewaresNoLogging appPlain

Ref: