WebhookNotifier

class WebhookNotifier(uri: URI, format: WebhookNotifier.Format = Format.GENERIC, kinds: Set<ParkedNotice.Kind> = ParkedNotice.Kind.entries.toSet(), service: String? = null, headers: Map<String, String> = emptyMap(), timeout: Duration = DEFAULT_TIMEOUT, client: HttpClient = HttpClient.newBuilder().connectTimeout(timeout.toJavaDuration()).build()) : ParkedNotifier

Posts each ParkedNotice of kinds to the webhook at uri, as JSON, through the JDK's HTTP client within timeout: a response other than 2xx fails the notification, which the runtime logs.

  • Format.GENERIC: {"event", "service", "group", "at", "entry", "text"}, entry as the operator's routes write it (parkedRoutes) and text a Markdown summary.

  • Format.WECOM: a WeCom (企业微信) group robot's Markdown message, {"msgtype": "markdown", "markdown": {"content"}}, as 9.x's compensation webhook sent it; a robot that answers an errcode other than 0 fails the notification.

service names the service in the message; headers are added to each request (a token, say).

Constructors

Link copied to clipboard
constructor(uri: URI, format: WebhookNotifier.Format = Format.GENERIC, kinds: Set<ParkedNotice.Kind> = ParkedNotice.Kind.entries.toSet(), service: String? = null, headers: Map<String, String> = emptyMap(), timeout: Duration = DEFAULT_TIMEOUT, client: HttpClient = HttpClient.newBuilder().connectTimeout(timeout.toJavaDuration()).build())

Types

Link copied to clipboard
object Companion
Link copied to clipboard

The shape of the message posted.

Functions

Link copied to clipboard
fun bodyOf(notice: ParkedNotice): Map<String, Any?>

What is posted for notice.

Link copied to clipboard
open suspend override fun notify(notice: ParkedNotice)
Link copied to clipboard
fun textOf(notice: ParkedNotice): String

A Markdown summary of notice.

Link copied to clipboard
open override fun toString(): String