Version: v0.0.0-...-931f6ba Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 21 Imported by: 0




View Source
const (
	// AccessTokenURL 获取access_token的接口
	AccessTokenURL = ""


This section is empty.


func PostXMLWithTLS

func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error)

PostXMLWithTLS perform a HTTP/POST request with XML body and TLS


type AuthBaseInfo

type AuthBaseInfo struct {
	FuncInfo []AuthFuncInfo `json:"func_info"`

AuthBaseInfo 授权的基本信息

type AuthFuncInfo

type AuthFuncInfo struct {
	FuncscopeCategory ID `json:"funcscope_category"`

AuthFuncInfo 授权的接口内容

type AuthorizerInfo

type AuthorizerInfo struct {
	NickName        string `json:"nick_name"`
	HeadImg         string `json:"head_img"`
	ServiceTypeInfo ID     `json:"service_type_info"`
	VerifyTypeInfo  ID     `json:"verify_type_info"`
	UserName        string `json:"user_name"`
	PrincipalName   string `json:"principal_name"`
	BusinessInfo    struct {
		OpenStore string `json:"open_store"`
		OpenScan  string `json:"open_scan"`
		OpenPay   string `json:"open_pay"`
		OpenCard  string `json:"open_card"`
		OpenShake string `json:"open_shake"`
	Alias     string `json:"alias"`
	QrcodeURL string `json:"qrcode_url"`

AuthorizerInfo 授权方详细信息

type AuthrAccessToken

type AuthrAccessToken struct {
	Appid        string `json:"authorizer_appid"`
	AccessToken  string `json:"authorizer_access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"authorizer_refresh_token"`

AuthrAccessToken 授权方AccessToken

type ComponentAccessToken

type ComponentAccessToken struct {
	AccessToken string `json:"component_access_token"`
	ExpiresIn   int64  `json:"expires_in"`

ComponentAccessToken 第三方平台

type Context

type Context struct {
	AppID          string
	AppSecret      string
	Token          string
	EncodingAESKey string
	PayMchID       string
	PayNotifyURL   string
	PayKey         string

	Cache       cache.Cache
	RestyClient *ehttp.Component

	Writer  http.ResponseWriter
	Request *http.Request
	// contains filtered or unexported fields

Context struct

func (*Context) GetAccessToken

func (ctx *Context) GetAccessToken() (accessToken string, err error)

GetAccessToken 获取access_token

func (*Context) GetAccessTokenFromServer

func (ctx *Context) GetAccessTokenFromServer() (resAccessToken ResAccessToken, err error)

GetAccessTokenFromServer 强制从微信服务器获取token

func (*Context) GetAuthrAccessToken

func (ctx *Context) GetAuthrAccessToken(appid string) (string, error)

GetAuthrAccessToken 获取授权方AccessToken

func (*Context) GetAuthrInfo

func (ctx *Context) GetAuthrInfo(appid string) (*AuthorizerInfo, *AuthBaseInfo, error)

GetAuthrInfo 获取授权方的帐号基本信息

func (*Context) GetComponentAccessToken

func (ctx *Context) GetComponentAccessToken() (string, error)

GetComponentAccessToken 获取 ComponentAccessToken

func (*Context) GetJsAPITicketLock

func (ctx *Context) GetJsAPITicketLock() *sync.RWMutex

GetJsAPITicketLock 获取jsAPITicket 的lock

func (*Context) GetPreCode

func (ctx *Context) GetPreCode() (string, error)

GetPreCode 获取预授权码

func (*Context) GetQuery

func (ctx *Context) GetQuery(key string) (string, bool)

GetQuery is like Query(), it returns the keyed url query value

func (*Context) GetQyAccessToken

func (ctx *Context) GetQyAccessToken() (accessToken string, err error)

GetQyAccessToken 获取access_token

func (*Context) GetQyAccessTokenFromServer

func (ctx *Context) GetQyAccessTokenFromServer() (resQyAccessToken ResQyAccessToken, err error)

GetQyAccessTokenFromServer 强制从微信服务器获取token

func (*Context) HTTPGet

func (ctx *Context) HTTPGet(uri string) ([]byte, error)

HTTPGet get 请求

func (*Context) HTTPPost

func (ctx *Context) HTTPPost(uri string, data string) ([]byte, error)

HTTPPost post 请求

func (*Context) PostFile

func (ctx *Context) PostFile(fieldname, filename, uri string) ([]byte, error)

PostFile 上传文件

func (*Context) PostJSON

func (ctx *Context) PostJSON(uri string, obj interface{}) ([]byte, error)

PostJSON post json 数据请求

func (*Context) PostJSONWithRespContentType

func (ctx *Context) PostJSONWithRespContentType(uri string, obj interface{}) ([]byte, string, error)

PostJSONWithRespContentType post json数据请求,且返回数据类型

func (*Context) PostMultipartForm

func (ctx *Context) PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)

PostMultipartForm 上传文件或其他多个字段

func (*Context) PostXML

func (ctx *Context) PostXML(uri string, obj interface{}) ([]byte, error)

PostXML perform a HTTP/POST request with XML body

func (*Context) Query

func (ctx *Context) Query(key string) string

Query returns the keyed url query value if it exists

func (*Context) QueryAuthCode

func (ctx *Context) QueryAuthCode(authCode string) (*AuthBaseInfo, error)

QueryAuthCode 使用授权码换取公众号或小程序的接口调用凭据和授权信息

func (*Context) RefreshAuthrToken

func (ctx *Context) RefreshAuthrToken(appid, refreshToken string) (*AuthrAccessToken, error)

RefreshAuthrToken 获取(刷新)授权公众号或小程序的接口调用凭据(令牌)

func (*Context) Render

func (ctx *Context) Render(bytes []byte)

Render render from bytes

func (*Context) SetAccessTokenLock

func (ctx *Context) SetAccessTokenLock(l *sync.RWMutex)

SetAccessTokenLock 设置读写锁(一个appID一个读写锁)

func (*Context) SetComponentAccessToken

func (ctx *Context) SetComponentAccessToken(verifyTicket string) (*ComponentAccessToken, error)

SetComponentAccessToken 通过component_verify_ticket 获取 ComponentAccessToken

func (*Context) SetGetAccessTokenFunc

func (ctx *Context) SetGetAccessTokenFunc(f GetAccessTokenFunc)

SetGetAccessTokenFunc 设置自定义获取accessToken的方式, 需要自己实现缓存

func (*Context) SetJsAPITicketLock

func (ctx *Context) SetJsAPITicketLock(lock *sync.RWMutex)

SetJsAPITicketLock 设置jsAPITicket的lock

func (*Context) SetQyAccessTokenLock

func (ctx *Context) SetQyAccessTokenLock(l *sync.RWMutex)

SetQyAccessTokenLock 设置读写锁(一个appID一个读写锁)

func (*Context) String

func (ctx *Context) String(str string)

String render from string

func (*Context) XML

func (ctx *Context) XML(obj interface{})

XML render to xml

type GetAccessTokenFunc

type GetAccessTokenFunc func(ctx *Context) (accessToken string, err error)

GetAccessTokenFunc 获取 access token 的函数签名

type ID

type ID struct {
	ID int `json:"id"`

ID 微信返回接口中各种类型字段

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string

MultipartFormField 保存文件或其他字段信息

type ResAccessToken

type ResAccessToken struct {

	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`

ResAccessToken struct

type ResQyAccessToken

type ResQyAccessToken struct {

	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`

ResQyAccessToken struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL