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

实现消息解密

This commit is contained in:
wenzl
2016-09-10 11:53:06 +08:00
parent f3303e2bb3
commit e713b4ffb2
7 changed files with 388 additions and 0 deletions

39
context/context.go Normal file
View File

@@ -0,0 +1,39 @@
package context
import "net/http"
//Context struct
type Context struct {
AppID string
AppSecret string
Token string
EncodingAESKey string
Writer http.ResponseWriter
Request *http.Request
}
func (ctx *Context) getAccessToken() {
}
func (ctx *Context) String(str string) error {
ctx.Writer.WriteHeader(200)
_, err := ctx.Writer.Write([]byte(str))
return err
}
// Query returns the keyed url query value if it exists
func (ctx *Context) Query(key string) string {
value, _ := ctx.GetQuery(key)
return value
}
// GetQuery is like Query(), it returns the keyed url query value
func (ctx *Context) GetQuery(key string) (string, bool) {
req := ctx.Request
if values, ok := req.URL.Query()[key]; ok && len(values) > 0 {
return values[0], true
}
return "", false
}