Documentation
¶
Overview ¶
*
- RESTful API implementation
- GET /wx -- 用于实现服务号接口配置,实际路径通过http路由关联
- POST /wx -- 处理微信消息/事件的入口,实际路径通过http路由关联
- GET /redirect -- 微信网页授权接口,处理服务号菜单的总入口,
- 不同菜单通过网页授权参数state区分,实际路径通过http路由关联
- Rosbit Xu
*
- 注册微信消息/事件处理函数,用于覆盖缺省处理函数
- 当前处理的消息/事件未全部覆盖,可以根据需要在此扩充
*
- signature checker as a http middleware
- Rosbit Xu
Index ¶
- func Echo(w http.ResponseWriter, r *http.Request)
- func InitWxAPI(workerNum int, logger io.Writer)
- func NewWxSignatureChecker(wxToken string, timeout int, uriPrefixes []string) func(http.ResponseWriter, *http.Request, http.HandlerFunc)
- func Redirect(w http.ResponseWriter, r *http.Request)
- func RegisterRedictHandler(handler RedirectHandler)
- func RegisterSubscribeEventHandler(handler SubscribeEventHandler)
- func RegisterTextMsgHandler(handler TextMsgHandler)
- func RegisterViewEventHandler(handler ViewEventHandler)
- func Request(w http.ResponseWriter, r *http.Request)
- func UnregisterSubscribeEventHandler(handler UnsubscribeEventHandler)
- type RedirectHandler
- type SubscribeEventHandler
- type TextMsgHandler
- type UnsubscribeEventHandler
- type ViewEventHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewWxSignatureChecker ¶
func NewWxSignatureChecker(wxToken string, timeout int, uriPrefixes []string) func(http.ResponseWriter, *http.Request, http.HandlerFunc)
*
- 创建http处理中间件,验证消息签名,如果非法直接返回错误
- @param wxToken 公众号在微信管理后台定义的token
- @param timeout 消失时间戳超时处理,秒数,如果<=0不检查时间戳
- @param uriPrefixes 需要检查签名的URI前缀列表,不相关的URI忽略检查;如果为nil,全部检查
func RegisterSubscribeEventHandler ¶
func RegisterSubscribeEventHandler(handler SubscribeEventHandler)
func RegisterTextMsgHandler ¶
func RegisterTextMsgHandler(handler TextMsgHandler)
func RegisterViewEventHandler ¶
func RegisterViewEventHandler(handler ViewEventHandler)
func UnregisterSubscribeEventHandler ¶
func UnregisterSubscribeEventHandler(handler UnsubscribeEventHandler)
Types ¶
type RedirectHandler ¶
type RedirectHandler func(openId, state string) (c string, h map[string]string, r string, err error)
*
- [函数签名]根据服务号菜单state做跳转
- @param openId 订阅用户的openId
- @param state 微信网页授权中的参数,用来标识某个菜单
- @return
- c 需要显示服务号对话框中的内容
- h 需要在微信内嵌浏览器中设置的header信息,包括Cookie
- r 需要通过302跳转的URL。如果r不是空串,c的内容被忽略
- err 如果没有错误返回nil,非nil表示错误
type SubscribeEventHandler ¶
type SubscribeEventHandler func(*wxmsg.SubscribeEvent) wxmsg.ReplyMsg // 用户关注(subscribe)服务号事件处理
type TextMsgHandler ¶
type TextMsgHandler func(*wxmsg.TextMsg) wxmsg.ReplyMsg // text消息处理
type UnsubscribeEventHandler ¶
type UnsubscribeEventHandler func(*wxmsg.SubscribeEvent) wxmsg.ReplyMsg // 用户取消关注(unsubscribe)服务号事件处理
type ViewEventHandler ¶
type ViewEventHandler func(*wxmsg.ViewEvent) wxmsg.ReplyMsg // VIEW事件处理
Source Files
¶
Click to show internal directories.
Click to hide internal directories.