https://github.com/psibi/wai-slack-middleware
A Slack middleware for wai
https://github.com/psibi/wai-slack-middleware
haskell middleware slack wai
Last synced: about 1 year ago
JSON representation
A Slack middleware for wai
- Host: GitHub
- URL: https://github.com/psibi/wai-slack-middleware
- Owner: psibi
- License: bsd-3-clause
- Created: 2017-04-23T15:25:50.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T12:11:05.000Z (over 7 years ago)
- Last Synced: 2024-04-25T12:20:21.615Z (about 2 years ago)
- Topics: haskell, middleware, slack, wai
- Language: Shell
- Size: 147 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# wai-slack-middleware
[](https://travis-ci.org/psibi/wai-slack-middleware) [](https://dev.azure.com/psibi2000/wai-slack-middleware/_build/latest?definitionId=1?branchName=master)
A Slack middleware for [wai](https://www.stackage.org/package/wai)
Used for logging the request information into Slack from a WAI
application via middleware.
## Usage:
Settings are controlled via the type `SlackConfig`:
``` haskell
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:
``` haskell
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:
* [Slack messages API](https://api.slack.com/docs/messages)