1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-15 02:02:27 +08:00

Merge pull request #83 from Chyroc/skip-valid-when-debug-mode

skip-valid-when-debug-mode(fix #82)
This commit is contained in:
silenceper
2018-09-12 14:02:11 +08:00
committed by GitHub
5 changed files with 29 additions and 18 deletions

1
.gitignore vendored
View File

@@ -25,3 +25,4 @@ _testmain.go
.DS_Store .DS_Store
.vscode/ .vscode/
vendor/*/ vendor/*/
.idea/

View File

@@ -18,6 +18,8 @@ import (
type Server struct { type Server struct {
*context.Context *context.Context
debug bool
openID string openID string
messageHandler func(message.MixMessage) *message.Reply messageHandler func(message.MixMessage) *message.Reply
@@ -40,6 +42,11 @@ func NewServer(context *context.Context) *Server {
return srv return srv
} }
// SetDebug set debug field
func (srv *Server) SetDebug(debug bool) {
srv.debug = debug
}
//Serve 处理微信的请求消息 //Serve 处理微信的请求消息
func (srv *Server) Serve() error { func (srv *Server) Serve() error {
if !srv.Validate() { if !srv.Validate() {
@@ -65,6 +72,9 @@ func (srv *Server) Serve() error {
//Validate 校验请求是否合法 //Validate 校验请求是否合法
func (srv *Server) Validate() bool { func (srv *Server) Validate() bool {
if srv.debug {
return true
}
timestamp := srv.Query("timestamp") timestamp := srv.Query("timestamp")
nonce := srv.Query("nonce") nonce := srv.Query("nonce")
signature := srv.Query("signature") signature := srv.Query("signature")

View File

@@ -10,10 +10,10 @@ import (
"github.com/silenceper/wechat/material" "github.com/silenceper/wechat/material"
"github.com/silenceper/wechat/menu" "github.com/silenceper/wechat/menu"
"github.com/silenceper/wechat/oauth" "github.com/silenceper/wechat/oauth"
"github.com/silenceper/wechat/pay"
"github.com/silenceper/wechat/server" "github.com/silenceper/wechat/server"
"github.com/silenceper/wechat/template" "github.com/silenceper/wechat/template"
"github.com/silenceper/wechat/user" "github.com/silenceper/wechat/user"
"github.com/silenceper/wechat/pay"
) )
// Wechat struct // Wechat struct