Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chiefy/go-slack-utils
Some wrappers for incoming webhooks, Block Kit UI and message authentication for Slack
https://github.com/chiefy/go-slack-utils
block-kit blockkit middleware slack slack-utils
Last synced: 5 days ago
JSON representation
Some wrappers for incoming webhooks, Block Kit UI and message authentication for Slack
- Host: GitHub
- URL: https://github.com/chiefy/go-slack-utils
- Owner: chiefy
- License: mit
- Created: 2020-01-01T17:55:27.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-12T16:42:19.000Z (about 2 years ago)
- Last Synced: 2024-04-15T03:18:49.749Z (7 months ago)
- Topics: block-kit, blockkit, middleware, slack, slack-utils
- Language: Go
- Size: 18.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-slack-utils
[![GoDoc](https://godoc.org/github.com/chiefy/go-slack-utils?status.svg)](https://godoc.org/github.com/chiefy/go-slack-utils)
## What this is?
This is a general purpose utility library for using Slack's [Block kit UI](https://api.slack.com/reference/block-kit/blocks), with Go structs corresponding to the blocks used to create UI elements. Also included is middleware for validing Slack requests using HMAC-256 and the Slack secret signing key.
## What this is not?
A Slack API wrapper. There's plenty of those out there.
## Installation
```bash
go get -u github.com/chiefy/go-slack-utils
```## Usage
### Middleware
```go
func main() {
r := mux.NewRouter()
r.HandleFunc("/command", MySlashCommandHandler).Methods(http.MethodPost)
r.Use(middleware.ValidateTimestamp)// It's up to you on how you configure injection of the slack signing secret
signingSecret := os.Getenv("SLACK_SIGNING_SECRET")
// Generate the validation middleware by injecting the secret
validateReq := middleware.ValidateSlackRequest(signingSecret)
r.Use(validateReq)srv := &http.Server{
Handler: r,
Addr: "127.0.0.1:" + os.Getenv("PORT"),
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Fatal(srv.ListenAndServe())
}
```