Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzl committed Sep 19, 2016
1 parent 59a2d41 commit 11cca83
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/silenceper/wechat/cache"
)

//Context struct
// Context struct
type Context struct {
AppID string
AppSecret string
Expand Down Expand Up @@ -41,12 +41,12 @@ func (ctx *Context) GetQuery(key string) (string, bool) {
return "", false
}

//SetJsAPITicketLock 设置jsAPITicket的lock
// SetJsAPITicketLock 设置jsAPITicket的lock
func (ctx *Context) SetJsAPITicketLock(lock *sync.RWMutex) {
ctx.jsAPITicketLock = lock
}

//GetJsAPITicketLock 获取jsAPITicket 的lock
// GetJsAPITicketLock 获取jsAPITicket 的lock
func (ctx *Context) GetJsAPITicketLock() *sync.RWMutex {
return ctx.jsAPITicketLock
}
6 changes: 3 additions & 3 deletions js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import (

const getTicketURL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi"

//Js struct
// Js struct
type Js struct {
*context.Context
}

//Config 返回给用户jssdk配置信息
// Config 返回给用户jssdk配置信息
type Config struct {
AppID string
TimeStamp int64
NonceStr string
Signature string
}

//resTicket 请求jsapi_tikcet返回结果
// resTicket 请求jsapi_tikcet返回结果
type resTicket struct {
util.CommonError

Expand Down
4 changes: 2 additions & 2 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package message

import "encoding/xml"

//MsgType 基本消息类型
// MsgType 基本消息类型
type MsgType string

//EventType 事件类型
// EventType 事件类型
type EventType string

const (
Expand Down
2 changes: 1 addition & 1 deletion util/error.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package util

//CommonError 微信返回的通用错误json
// CommonError 微信返回的通用错误json
type CommonError struct {
ErrCode int64 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Expand Down
16 changes: 8 additions & 8 deletions wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
"github.com/silenceper/wechat/server"
)

//Wechat struct
// Wechat struct
type Wechat struct {
Context *context.Context
}

//Config for user
// Config for user
type Config struct {
AppID string
AppSecret string
Expand All @@ -27,7 +27,7 @@ type Config struct {
Cache cache.Cache
}

//NewWechat init
// NewWechat init
func NewWechat(cfg *Config) *Wechat {
context := new(context.Context)
copyConfigToContext(cfg, context)
Expand All @@ -44,33 +44,33 @@ func copyConfigToContext(cfg *Config, context *context.Context) {
context.SetJsAPITicketLock(new(sync.RWMutex))
}

//GetServer 消息管理
// GetServer 消息管理
func (wc *Wechat) GetServer(req *http.Request, writer http.ResponseWriter) *server.Server {
wc.Context.Request = req
wc.Context.Writer = writer
return server.NewServer(wc.Context)
}

//GetMaterial 素材管理
// GetMaterial 素材管理
func (wc *Wechat) GetMaterial() *material.Material {
return material.NewMaterial(wc.Context)
}

//GetOauth oauth2网页授权
// GetOauth oauth2网页授权
func (wc *Wechat) GetOauth(req *http.Request, writer http.ResponseWriter) *oauth.Oauth {
wc.Context.Request = req
wc.Context.Writer = writer
return oauth.NewOauth(wc.Context)
}

//GetJs js-sdk配置
// GetJs js-sdk配置
func (wc *Wechat) GetJs(req *http.Request, writer http.ResponseWriter) *js.Js {
wc.Context.Request = req
wc.Context.Writer = writer
return js.NewJs(wc.Context)
}

//GetMenu 菜单管理接口
// GetMenu 菜单管理接口
func (wc *Wechat) GetMenu(req *http.Request, writer http.ResponseWriter) *menu.Menu {
wc.Context.Request = req
wc.Context.Writer = writer
Expand Down

0 comments on commit 11cca83

Please sign in to comment.