Documentation ¶
Overview ¶
*
- RESTful API implementation
- Rosbit Xu
*
- signature checker as a http middleware
- Rosbit Xu
Index ¶
- func CreateChannelsEcHandler(serviceName string, workerNum int, ...) http.HandlerFunc
- func CreateEcho(token string) http.HandlerFunc
- func CreateMsgHandler(serviceName string, workerNum int, msgHandler wxmsg.WxMsgHandler) http.HandlerFunc
- func CreateOAuth2Redirector(serviceName string, workerNum int, redirectUrl string, userInfoFlag ...string) http.HandlerFunc
- func InitWx(tokenStorePath string)
- func NewWxSignatureChecker(wxToken string, timeout int, uriPrefixes []string) func(http.ResponseWriter, *http.Request, http.HandlerFunc)
- func SetWxParams(serviceName string, token, appId, appSecret, aesKey string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChannelsEcHandler ¶ added in v2.1.0
func CreateChannelsEcHandler(serviceName string, workerNum int, channelsEcEventHandler wxmsg.ChannelsEcEventHandler) http.HandlerFunc
创建视频号小店事件处理入口 路由方法: POST @param serviceName 配置项的名称 @parma workerNum 处理消息的并发数 @param channelsEcEventHandler 视频号小店事件处理器,根据实际情况实现
func CreateEcho ¶
func CreateEcho(token string) http.HandlerFunc
用于微信服务号设置 路由方法: GET uri?signature=xxx=timestamp=xxx&nonce=xxx&echostr=xxx
func CreateMsgHandler ¶
func CreateMsgHandler(serviceName string, workerNum int, msgHandler wxmsg.WxMsgHandler) http.HandlerFunc
创建微信服务号消息/事件处理入口 路由方法: POST @param serviceName 配置项的名称 @parma workerNum 处理消息的并发数 @param msgHandler 消息/事件处理器,根据实际情况实现
func CreateOAuth2Redirector ¶
func CreateOAuth2Redirector(serviceName string, workerNum int, redirectUrl string, userInfoFlag ...string) http.HandlerFunc
创建网页授权处理器 路由方法: GET @param serviceName 配置项的名称 @parma workerNum 处理消息的并发数 @param redirectUrl 该URL将全权决定网页授权的处理
请求方式: POST 请求BODY: 是一个JSON: {"appId": "xxx", "openId": "xxx", "state": "state"} 该URL的以POST形式接收参数,而且会得到所有的HTTP头信息,可以设置任何的响应头信息 响应结果直接显示在公众号浏览器中,响应时间要控制好,避免微信服务超时
@param userInfoFlag 只取第一项,用于检查转发url中是否有标志串;该值存在表示使用 snsapi_userinfo 获取用户信息
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,全部检查
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.