webhook

package
v0.0.0-...-fcc14e7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyBody = errors.New("empty body")

ErrEmptyBody ...

View Source
var ErrSignatureMismatch = errors.New("signature mismatch")

ErrSignatureMismatch signature mismatch

Functions

func DefaultEchoHandle

func DefaultEchoHandle(token string, w http.ResponseWriter, r *http.Request)

DefaultEchoHandle This is the default Echo Handle, which will be used when WeChat Public sends an authentication request

func SHA1Sign

func SHA1Sign(args ...string) string

SHA1Sign Computing signatures using sha1

Types

type ArticleMessage

type ArticleMessage struct {
	// contains filtered or unexported fields
}

ArticleMessage ...

type EncryptMessage

type EncryptMessage struct {
	// Encrypt ...
	Encrypt string `xml:"Encrypt"`
	// MsgSignature ...
	MsgSignature string `xml:"MsgSignature"`
	// TimeStamp ...
	TimeStamp int64 `xml:"TimeStamp"`
	// Nonce ...
	Nonce string `xml:"Nonce"`

	PlainMessage
}

EncryptMessage ...

func ValidateWebhook

func ValidateWebhook(r *http.Request, token string) (msg *EncryptMessage, payload []byte, encrypted bool, err error)

ValidateWebhook ...

type GetTokenFunc

type GetTokenFunc func() (string, error)

GetTokenFunc ...

type ImageMessage

type ImageMessage struct {
	// contains filtered or unexported fields
}

ImageMessage ...

type MessageHandle

type MessageHandle func(ctx context.Context, msg *PlainMessage) (Messager, error)

MessageHandle ...

type Messager

type Messager interface {
	// contains filtered or unexported methods
}

Messager ..

type MusicMessage

type MusicMessage struct {
	// contains filtered or unexported fields
}

MusicMessage ...

type Option

type Option func(*Server)

Option ...

func WithPlainMode

func WithPlainMode(token string) Option

WithPlainMode ...

func WithSafeMode

func WithSafeMode(token, encodingAESKey string) Option

WithSafeMode ...

type PlainMessage

type PlainMessage struct {
	// ToUserName 开发者微信号
	ToUserName string `xml:"ToUserName"`

	// FromUserName 发送方帐号(一个OpenID)
	FromUserName string `xml:"FromUserName"`

	// CreateTime 消息创建时间 (整型)
	CreateTime int64 `xml:"CreateTime"`

	// MsgType 消息类型,文本为text
	MsgType string `xml:"MsgType"`

	// MsgID 消息id,64位整型
	MsgID int64 `xml:"MsgId"`

	// Content 文本消息内容
	Content string `xml:"Content"`

	// Event 事件类型,subscribe
	Event string `xml:"Event"`
}

PlainMessage ...

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements http.Handler. It validates incoming WeChat Public Platform webhooks and then dispatches them to the appropriate plugins.

func NewServer

func NewServer(appid string, opts ...Option) (*Server, error)

NewServer not implemented

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements an http.Handler that answers callback requests.

type TextMessage

type TextMessage struct {
	Content string
	// contains filtered or unexported fields
}

TextMessage ...

type VideoMessage

type VideoMessage struct {

	// MediaID 通过素材管理中的接口上传多媒体文件,得到的id。
	MediaID string `xml:"MediaId"`

	// Title 视频消息的标题
	Title string `xml:"Title"`

	// Description 视频消息的描述
	Description string `xml:"Description"`
	// contains filtered or unexported fields
}

VideoMessage ...

type VoiceMessage

type VoiceMessage struct {
	// contains filtered or unexported fields
}

VoiceMessage ...

type WXBizMsgCrypto

type WXBizMsgCrypto struct {
	// contains filtered or unexported fields
}

WXBizMsgCrypto ...

func NewWXBizMsgCrypto

func NewWXBizMsgCrypto(encodingAESKey, appID, token string) (*WXBizMsgCrypto, error)

NewWXBizMsgCrypto ...

func (*WXBizMsgCrypto) DecryptMessage

func (wc *WXBizMsgCrypto) DecryptMessage(payload []byte, v interface{}) error

DecryptMessage ...

func (*WXBizMsgCrypto) EncryptMessage

func (wc *WXBizMsgCrypto) EncryptMessage(payload []byte, timestamp int64, nonce string) ([]byte, error)

EncryptMessage ...

type WXBizMsgCryptor

type WXBizMsgCryptor interface {
	DecryptMessage(payload []byte, v interface{}) error
	EncryptMessage(payload []byte, timestamp int64, nonce string) ([]byte, error)
}

WXBizMsgCryptor ...

Jump to

Keyboard shortcuts

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