caddyslack

package module
v0.0.0-...-0301071 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

caddyslack Build Status Coverage Status Go Report Card

Caddy plugin to filter and relay incoming WebHook requests to slack

slack [endpoint] {
  url https://hooks.slack.com/services/ID/ID/TOKEN
  [only]
    [json.field.to.keep]
    [json.field.to.keep.as.well]
  [delete]
    [json.field.to.delete]
    [json.field.to.delete.as.well]
}

Examples

Full Example with ratelimit

ratelimit caddy plugin

slack /toSlack {
  url https://hooks.slack.com/services/ID/ID/TOKEN
  only
    text
}
ratelimit /toSlack 2 3

The endpoint /toSlack accepts 2 or 3 (with burst) POST requests per second. The json-body will be filtered for everything except text, and forwarded to https://hooks.slack.com/services/ID/ID/TOKEN

delete

Caddyfile

slack /toSlack {
  url https://hooks.slack.com/services/ID/ID/TOKEN
  delete
    attachments.title
}

A POST request to /toSlack with the following body

{
  "text": "Hello",
  "attachments": [
        {
            "title": "App hangs on reboot",
            "text": "If I restart my computer without quitting your app, it stops the reboot sequence.",
        }
    ]
}

will be forwarded to https://hooks.slack.com/services/ID/ID/TOKEN as

{
  "text": "Hello",
  "attachments": [
        {
            "text": "If I restart my computer without quitting your app, it stops the reboot sequence.",
        }
    ]
}
only

Caddyfile

slack /toSlack {
  url https://hooks.slack.com/services/ID/ID/TOKEN
  only
    text
    icon
}

A POST request to /toSlack with the following body

{
  "text": "Hello",
  "channel": "notallowed",
  "icon": "ghost"
}

will be forwarded to https://hooks.slack.com/services/ID/ID/TOKEN as

{
  "text": "Hello",
  "icon": "ghost"
}

Documentation

Index

Constants

View Source
const StatusEmpty = 0

StatusEmpty returned by mailout middleware because the proper status gets written previously

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONError

type JSONError struct {
	// Code represents the HTTP Status Code, a work around.
	Code int `json:"code,omitempty"`
	// Error the underlying error, if there is one.
	Error string `json:"error,omitempty"`
}

JSONError defines how an REST JSON looks like. Code 200 and empty Error specifies a successful request Any other Code value s an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL