mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-11 00:02:27 +08:00
skip-valid-when-debug-mode(fix #82)
This commit is contained in:
@@ -18,6 +18,8 @@ import (
|
||||
type Server struct {
|
||||
*context.Context
|
||||
|
||||
debug bool
|
||||
|
||||
openID string
|
||||
|
||||
messageHandler func(message.MixMessage) *message.Reply
|
||||
@@ -40,6 +42,11 @@ func NewServer(context *context.Context) *Server {
|
||||
return srv
|
||||
}
|
||||
|
||||
// SetDebug set debug field
|
||||
func (srv *Server) SetDebug(debug bool) {
|
||||
srv.debug = debug
|
||||
}
|
||||
|
||||
//Serve 处理微信的请求消息
|
||||
func (srv *Server) Serve() error {
|
||||
if !srv.Validate() {
|
||||
@@ -65,6 +72,9 @@ func (srv *Server) Serve() error {
|
||||
|
||||
//Validate 校验请求是否合法
|
||||
func (srv *Server) Validate() bool {
|
||||
if srv.debug {
|
||||
return true
|
||||
}
|
||||
timestamp := srv.Query("timestamp")
|
||||
nonce := srv.Query("nonce")
|
||||
signature := srv.Query("signature")
|
||||
|
||||
Reference in New Issue
Block a user