Documentation ¶
Index ¶
- Constants
- Variables
- type AccessToken
- func (accessToken *AccessToken) ApplyToRequest(request *http.Request, requestOptions *object.HashMap) (*http.Request, error)
- func (accessToken *AccessToken) GetCacheKey() string
- func (accessToken *AccessToken) GetRefreshedToken() (*response2.ResponseGetToken, error)
- func (accessToken *AccessToken) GetToken(refresh bool) (resToken *response2.ResponseGetToken, err error)
- func (accessToken *AccessToken) Refresh() contract.AccessTokenInterface
- func (accessToken *AccessToken) SetToken(token string, lifeTime int) (tokenInterface contract.AccessTokenInterface, err error)
- type ApplicationInterface
- type BaseClient
- func (client *BaseClient) HttpGet(url string, query interface{}, outHeader interface{}, outBody interface{}) (interface{}, error)
- func (client *BaseClient) HttpPost(url string, data interface{}, outHeader interface{}, outBody interface{}) (interface{}, error)
- func (client *BaseClient) HttpPostJson(url string, data interface{}, query interface{}, outHeader interface{}, ...) (interface{}, error)
- func (client *BaseClient) HttpUpload(url string, files *object.HashMap, form *object.HashMap, query interface{}, ...) (interface{}, error)
- func (client *BaseClient) Request(url string, method string, options *object.HashMap, returnRaw bool, ...) (interface{}, error)
- func (client *BaseClient) RequestRaw(url string, method string, options *object.HashMap, outHeader interface{}, ...) (interface{}, error)
- type CDATA
- type Config
- type Encryptor
- func (encryptor *Encryptor) Decrypt(content []byte, msgSignature, nonce, timestamp string) ([]byte, *support.CryptError)
- func (encryptor *Encryptor) Encrypt(msg, nonce, timestamp string) ([]byte, *support.CryptError)
- func (encryptor *Encryptor) GetToken() string
- func (encryptor *Encryptor) Signature(token, timestamp, nonce, data string) string
- func (encryptor *Encryptor) VerifyUrl(content string, msgSignature, nonce, timestamp string) ([]byte, *support.CryptError)
- type InteractsWithCache
- type Middleware
- type MiddlewareAccessToken
- type MiddlewareLogMiddleware
- type MiddlewareRetry
- type ServerGuard
- type ServiceContainer
- type WeComRecvMsg
- type WeComReplyMsg
Constants ¶
const ( ErrorInvalidSignature = -40001 // 签名验证错误 ErrorParseXml = -40002 // xml/json解析失败 ErrorCalcSignature = -40003 // sha加密生成签名失败 ErrorInvalidAesKey = -40004 // AESKey 非法 ErrorInvalidAppId = -40005 // ReceiveId 校验错误 ErrorEncryptAes = -40006 // AES 加密失败 ErrorDecryptAes = -40007 // AES 解密失败 ErrorInvalidXml = -40008 // 解密后得到的buffer非法 ErrorBase64Encode = -40009 // base64 编码失败 ErrorBase64Decode = -40010 // base64 解码失败 ErrorXmlBuild = -40011 // 生成xml失败 IllegalBuffer = -41003 // Illegal buffer )
Wechat Docs: https://open.work.weixin.qq.com/api/doc/90000/90138/90307
const SUCCESS_EMPTY_RESPONSE = "success"
Variables ¶
var MESSAGE_TYPE_MAPPING = map[string]int{ "*": messages.VOID, "text": messages.TEXT, "image": messages.IMAGE, "voice": messages.VOICE, "video": messages.VIDEO, "shortvideo": messages.SHORT_VIDEO, "location": messages.LOCATION, "link": messages.LINK, "device_event": messages.DEVICE_EVENT, "device_text": messages.DEVICE_TEXT, "event": messages.EVENT, "file": messages.FILE, "miniprogrampage": messages.MINIPROGRAM_PAGE, }
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { App *ApplicationInterface *request.HttpRequest *response.HttpResponse RequestMethod string EndpointToGetToken string QueryName string Token object.HashMap TokenKey string CachePrefix string *InteractsWithCache GetCredentials func() *object.StringMap }
func NewAccessToken ¶
func NewAccessToken(app *ApplicationInterface) *AccessToken
func (*AccessToken) ApplyToRequest ¶
func (*AccessToken) GetCacheKey ¶
func (accessToken *AccessToken) GetCacheKey() string
func (*AccessToken) GetRefreshedToken ¶
func (accessToken *AccessToken) GetRefreshedToken() (*response2.ResponseGetToken, error)
func (*AccessToken) GetToken ¶
func (accessToken *AccessToken) GetToken(refresh bool) (resToken *response2.ResponseGetToken, err error)
func (*AccessToken) Refresh ¶
func (accessToken *AccessToken) Refresh() contract.AccessTokenInterface
func (*AccessToken) SetToken ¶
func (accessToken *AccessToken) SetToken(token string, lifeTime int) (tokenInterface contract.AccessTokenInterface, err error)
type ApplicationInterface ¶
type ApplicationInterface interface { GetContainer() *ServiceContainer GetAccessToken() *AccessToken GetConfig() *Config GetComponent(name string) interface{} SetExternalRequest(r *http.Request) GetExternalRequest() (r *http.Request) }
type BaseClient ¶
type BaseClient struct { *request.HttpRequest *response.HttpResponse *support.ResponseCastable ExternalRequest *http2.Request Signer *support.SHA256WithRSASigner App *ApplicationInterface Token *AccessToken }
func NewBaseClient ¶
func NewBaseClient(app *ApplicationInterface, token *AccessToken) *BaseClient
func (*BaseClient) HttpGet ¶
func (client *BaseClient) HttpGet(url string, query interface{}, outHeader interface{}, outBody interface{}) (interface{}, error)
func (*BaseClient) HttpPost ¶
func (client *BaseClient) HttpPost(url string, data interface{}, outHeader interface{}, outBody interface{}) (interface{}, error)
func (*BaseClient) HttpPostJson ¶
func (client *BaseClient) HttpPostJson(url string, data interface{}, query interface{}, outHeader interface{}, outBody interface{}) (interface{}, error)
func (*BaseClient) HttpUpload ¶
func (*BaseClient) RequestRaw ¶
type Config ¶
type Config struct {
*object.Collection
}
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
func NewEncryptor ¶
func (*Encryptor) Decrypt ¶
func (encryptor *Encryptor) Decrypt(content []byte, msgSignature, nonce, timestamp string) ([]byte, *support.CryptError)
Decrypt decrypt xml msg and return xml
func (*Encryptor) Encrypt ¶
func (encryptor *Encryptor) Encrypt(msg, nonce, timestamp string) ([]byte, *support.CryptError)
Encrypt encrypt xml msg and return xml
func (*Encryptor) VerifyUrl ¶
func (encryptor *Encryptor) VerifyUrl(content string, msgSignature, nonce, timestamp string) ([]byte, *support.CryptError)
VerifyUrl Parsing the official WeChat callback validation. Wechat Docs: https://work.weixin.qq.com/api/doc/90000/90135/90235 When adding URLs to the WeChat admin backend, WeChat will trigger a GET request to verify whether the server can process the encrypted information properly, and the uniformMessage needs to be decrypted and returned. 在微信管理后台添加URL的时候,微信会触发一条GET请求用于验证服务器能否正常处理加密信息,需要将消息解密出来返回。 eg: "/app-callback?msg_signature=1495c4dfd4958d4e5faf618978ae66943a042f87×tamp=1623292419&nonce=1623324060&echostr=o1XtmVltGmUAqoWee54yd4Q5ZBgrw4%2F9lFo5qdZoVPd1DybzarjuYCfFlR2AFbAcWHwFgmbrVBD%2Bf9910QIF6g%3D%3D"
type InteractsWithCache ¶
type InteractsWithCache struct {
Cache cache.CacheInterface
}
func (*InteractsWithCache) GetCache ¶
func (interactCache *InteractsWithCache) GetCache() cache.CacheInterface
type Middleware ¶
type Middleware struct { contract.MiddlewareInterface *BaseClient Name string }
----------------------------------------------------------------------
func (*Middleware) Delay ¶
func (d *Middleware) Delay() time.Duration
func (*Middleware) GetName ¶
func (d *Middleware) GetName() string
func (*Middleware) Retries ¶
func (d *Middleware) Retries() int
func (*Middleware) RetryDecider ¶
func (d *Middleware) RetryDecider(conditions *object.HashMap) bool
func (*Middleware) SetName ¶
func (d *Middleware) SetName(name string)
type MiddlewareAccessToken ¶
type MiddlewareAccessToken struct {
*Middleware
}
func (*MiddlewareAccessToken) ModifyRequest ¶
func (d *MiddlewareAccessToken) ModifyRequest(req *http2.Request) (err error)
--- MiddlewareAccessToken ---
type MiddlewareLogMiddleware ¶
type MiddlewareLogMiddleware struct {
*Middleware
}
func (*MiddlewareLogMiddleware) ModifyRequest ¶
func (d *MiddlewareLogMiddleware) ModifyRequest(req *http2.Request) error
--- MiddlewareLogMiddleware ---
type MiddlewareRetry ¶
type MiddlewareRetry struct {
*Middleware
}
func (*MiddlewareRetry) ModifyRequest ¶
func (d *MiddlewareRetry) ModifyRequest(req *http2.Request) error
--- MiddlewareRetry ---
func (*MiddlewareRetry) RetryDecider ¶
func (d *MiddlewareRetry) RetryDecider(conditions *object.HashMap) bool
type ServerGuard ¶
type ServerGuard struct { *support.Observable *support.ResponseCastable App *ApplicationInterface IsSafeMode func() bool Validate func() (*ServerGuard, error) ShouldReturnRawResponse func() bool ToCallbackType func(callbackHeader contract.EventInterface, buf []byte) (decryptMessage interface{}, err error) // contains filtered or unexported fields }
func NewServerGuard ¶
func NewServerGuard(app *ApplicationInterface) *ServerGuard
func (*ServerGuard) Serve ¶
func (serverGuard *ServerGuard) Serve(r *http.Request) (response *response.HttpResponse, err error)
type ServiceContainer ¶
type ServiceContainer struct { ID int DefaultConfig *object.HashMap UserConfig *object.HashMap Config *object.HashMap }
func (*ServiceContainer) GetConfig ¶
func (container *ServiceContainer) GetConfig() *object.HashMap