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]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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 2017-05-06T01:03:06Z
Distributions LTSHaskell:0.2.0, NixOS:0.2.0, Stackage:0.2.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1907 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-06 [all 1 reports]

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: