Documentation ¶
Overview ¶
Package webhook 包含订阅事件相关功能, 主要功能由 Handler 提供
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( PayloadTypeURLVerification = "url_verification" PayloadTypeEventCallback = "event_callback" )
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler 是一个 http.Handler,用于处理订阅事件回调/自动处理 url_verification, 同时它也满足 AppTicketProvider, 可为应用商店应用提供 app ticket
func New ¶
func New(cnf conf.WebhookConfig, handler PayloadHandler) *Handler
New 创建一个 Handler,cnf 必须提供,handler 可用于处理感兴趣的事件, 也可以传入 nil
func (*Handler) FeishuAppTicket ¶
FeishuAppTicket 满足 AppTicketProvider 接口
type Payload ¶
type Payload struct { // Type 是类型: event_callback-事件推送,url_verification-url地址验证 Type string `json:"type"` // Token 即 Verification Token Token string `json:"token"` // Challenge 需要原样返回. type 为 url_verification 时有 Challenge string `json:"challenge"` // Timestamp 是事件发送时间,一般近似于事件发生的时间. type 为 event_callback 时有 Timestamp string `json:"ts"` // UUID 是事件的唯一标识, 主要用于保证幂等性. type 为 event_callback 时有 UUID string `json:"uuid"` // RawEvent 是未解析的事件内容. type 为 event_callback 时有 RawEvent json.RawMessage `json:"event"` // contains filtered or unexported fields }
Payload 是订阅事件的 payload
type PayloadHandler ¶
type PayloadHandler func(w http.ResponseWriter, r *http.Request, payload *Payload)
PayloadHandler 用于处理 webhook payload
Click to show internal directories.
Click to hide internal directories.