Documentation ¶
Overview ¶
Package wx is a generated GoMock package.
Index ¶
- func DecodeBytesToUint32(b []byte) uint32
- func EncodeUint32ToBytes(i uint32) []byte
- func FormatMap2XML(m WXML) (string, error)
- func MarshalWithNoEscapeHTML(v interface{}) ([]byte, error)
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func PKCS5Padding(cipherText []byte, blockSize int) []byte
- func PKCS5Unpadding(plainText []byte, blockSize int) []byte
- func RSADecrypt(cipherText, privateKey []byte) ([]byte, error)
- func RSAEncrypt(data, publicKey []byte) ([]byte, error)
- func ZeroPadding(cipherText []byte, blockSize int) []byte
- func ZeroUnPadding(plainText []byte) []byte
- type API
- type APIOption
- func WithBody(f func() ([]byte, error)) APIOption
- func WithDecode(f func(resp []byte) error) APIOption
- func WithMethod(method HTTPMethod) APIOption
- func WithQuery(key, value string) APIOption
- func WithTLS() APIOption
- func WithUploadForm(fieldname, filename string, extraFields map[string]string) APIOption
- func WithWXML(f func(appid, mchid, nonce string) (WXML, error)) APIOption
- type Action
- type CBCCrypto
- type CDATA
- type Client
- type ECBCrypto
- type HTTPClient
- func (h *HTTPClient) Get(ctx context.Context, url string, options ...HTTPOption) ([]byte, error)
- func (h *HTTPClient) Post(ctx context.Context, url string, body []byte, options ...HTTPOption) ([]byte, error)
- func (h *HTTPClient) PostXML(ctx context.Context, url string, body WXML, options ...HTTPOption) (WXML, error)
- func (h *HTTPClient) Upload(ctx context.Context, url string, form *UploadForm, options ...HTTPOption) ([]byte, error)
- type HTTPMethod
- type HTTPOption
- type MockAction
- func (m *MockAction) Body() ([]byte, error)
- func (m *MockAction) Decode() func([]byte) error
- func (m *MockAction) EXPECT() *MockActionMockRecorder
- func (m *MockAction) Method() HTTPMethod
- func (m *MockAction) TLS() bool
- func (m *MockAction) URL(accessToken ...string) string
- func (m *MockAction) UploadForm() *UploadForm
- func (m *MockAction) WXML(appid, mchid, nonce string) (WXML, error)
- type MockActionMockRecorder
- func (mr *MockActionMockRecorder) Body() *gomock.Call
- func (mr *MockActionMockRecorder) Decode() *gomock.Call
- func (mr *MockActionMockRecorder) Method() *gomock.Call
- func (mr *MockActionMockRecorder) TLS() *gomock.Call
- func (mr *MockActionMockRecorder) URL(accessToken ...interface{}) *gomock.Call
- func (mr *MockActionMockRecorder) UploadForm() *gomock.Call
- func (mr *MockActionMockRecorder) WXML(appid, mchid, nonce interface{}) *gomock.Call
- type MockClient
- func (m *MockClient) EXPECT() *MockClientMockRecorder
- func (m *MockClient) Get(ctx context.Context, reqURL string, options ...HTTPOption) ([]byte, error)
- func (m *MockClient) Post(ctx context.Context, reqURL string, body []byte, options ...HTTPOption) ([]byte, error)
- func (m *MockClient) PostXML(ctx context.Context, reqURL string, body WXML, options ...HTTPOption) (WXML, error)
- func (m *MockClient) Upload(ctx context.Context, reqURL string, form *UploadForm, options ...HTTPOption) ([]byte, error)
- type MockClientMockRecorder
- func (mr *MockClientMockRecorder) Get(ctx, reqURL interface{}, options ...interface{}) *gomock.Call
- func (mr *MockClientMockRecorder) Post(ctx, reqURL, body interface{}, options ...interface{}) *gomock.Call
- func (mr *MockClientMockRecorder) PostXML(ctx, reqURL, body interface{}, options ...interface{}) *gomock.Call
- func (mr *MockClientMockRecorder) Upload(ctx, reqURL, form interface{}, options ...interface{}) *gomock.Call
- type PaddingMode
- type UploadForm
- type WXML
- type X
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBytesToUint32 ¶
DecodeBytesToUint32 从 4 字节的网络字节序里解析出整数 uint32
func EncodeUint32ToBytes ¶
EncodeUint32ToBytes 把整数 uint32 格式化成 4 字节的网络字节序
func MarshalWithNoEscapeHTML ¶
MarshalWithNoEscapeHTML marshal with no escape HTML
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func NewECBEncrypter ¶
NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func PKCS5Padding ¶
func PKCS5Unpadding ¶
func RSADecrypt ¶
RSADecrypt rsa decryption with private key
func RSAEncrypt ¶
RSAEncrypt rsa encryption with public key
func ZeroPadding ¶
func ZeroUnPadding ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a Action implementation
func (*API) Method ¶
func (a *API) Method() HTTPMethod
func (*API) UploadForm ¶
func (a *API) UploadForm() *UploadForm
type APIOption ¶
type APIOption func(api *API)
APIOption configures how we set up the wechat API
func WithDecode ¶
WithDecode specifies the `decode` to API.
func WithMethod ¶
func WithMethod(method HTTPMethod) APIOption
WithMethod specifies the `method` to API.
func WithUploadForm ¶
WithUploadForm specifies the `upload form` to API.
type Action ¶
type Action interface { URL(accessToken ...string) string Method() HTTPMethod WXML(appid, mchid, nonce string) (WXML, error) Body() ([]byte, error) UploadForm() *UploadForm Decode() func(resp []byte) error TLS() bool }
Action is the interface that handle wechat api
type CBCCrypto ¶
type CBCCrypto struct {
// contains filtered or unexported fields
}
CBCCrypto aes-cbc crypto
func NewCBCCrypto ¶
NewCBCCrypto returns new aes-cbc crypto
type CDATA ¶
type CDATA string
CDATA XML CDATA section which is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup.
func (CDATA) MarshalXML ¶
MarshalXML encodes the receiver as zero or more XML elements.
type Client ¶
type Client interface { Get(ctx context.Context, reqURL string, options ...HTTPOption) ([]byte, error) Post(ctx context.Context, reqURL string, body []byte, options ...HTTPOption) ([]byte, error) PostXML(ctx context.Context, reqURL string, body WXML, options ...HTTPOption) (WXML, error) Upload(ctx context.Context, reqURL string, form *UploadForm, options ...HTTPOption) ([]byte, error) }
Client is the interface that do http request
type ECBCrypto ¶
type ECBCrypto struct {
// contains filtered or unexported fields
}
ECBCrypto aes-ecb crypto
func NewECBCrypto ¶
NewECBCrypto returns new aes-ecb crypto
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a Client implementation for wechat http request
func NewHTTPClient ¶
func NewHTTPClient(tlsCfg ...*tls.Config) *HTTPClient
NewHTTPClient returns a new http client
func (*HTTPClient) Get ¶
func (h *HTTPClient) Get(ctx context.Context, url string, options ...HTTPOption) ([]byte, error)
Get http get request
func (*HTTPClient) Post ¶
func (h *HTTPClient) Post(ctx context.Context, url string, body []byte, options ...HTTPOption) ([]byte, error)
Post http post request
func (*HTTPClient) PostXML ¶
func (h *HTTPClient) PostXML(ctx context.Context, url string, body WXML, options ...HTTPOption) (WXML, error)
PostXML http xml post request
func (*HTTPClient) Upload ¶
func (h *HTTPClient) Upload(ctx context.Context, url string, form *UploadForm, options ...HTTPOption) ([]byte, error)
Upload http upload media
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod http request method
const ( MethodGet HTTPMethod = "GET" MethodPost HTTPMethod = "POST" MethodUpload HTTPMethod = "UPLOAD" )
type HTTPOption ¶
type HTTPOption func(s *httpSettings)
HTTPOption configures how we set up the http request
func WithHTTPClose ¶
func WithHTTPClose() HTTPOption
WithHTTPClose specifies close the connection after replying to this request (for servers) or after sending this request and reading its response (for clients).
func WithHTTPCookies ¶
func WithHTTPCookies(cookies ...*http.Cookie) HTTPOption
WithHTTPCookies specifies the cookies to http request.
func WithHTTPHeader ¶
func WithHTTPHeader(key, value string) HTTPOption
WithHTTPHeader specifies the headers to http request.
func WithHTTPTimeout ¶
func WithHTTPTimeout(timeout time.Duration) HTTPOption
WithHTTPTimeout specifies the timeout to http request.
type MockAction ¶
type MockAction struct {
// contains filtered or unexported fields
}
MockAction is a mock of Action interface
func NewMockAction ¶
func NewMockAction(ctrl *gomock.Controller) *MockAction
NewMockAction creates a new mock instance
func (*MockAction) Decode ¶
func (m *MockAction) Decode() func([]byte) error
Decode mocks base method
func (*MockAction) EXPECT ¶
func (m *MockAction) EXPECT() *MockActionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockAction) URL ¶
func (m *MockAction) URL(accessToken ...string) string
URL mocks base method
func (*MockAction) UploadForm ¶
func (m *MockAction) UploadForm() *UploadForm
UploadForm mocks base method
type MockActionMockRecorder ¶
type MockActionMockRecorder struct {
// contains filtered or unexported fields
}
MockActionMockRecorder is the mock recorder for MockAction
func (*MockActionMockRecorder) Body ¶
func (mr *MockActionMockRecorder) Body() *gomock.Call
Body indicates an expected call of Body
func (*MockActionMockRecorder) Decode ¶
func (mr *MockActionMockRecorder) Decode() *gomock.Call
Decode indicates an expected call of Decode
func (*MockActionMockRecorder) Method ¶
func (mr *MockActionMockRecorder) Method() *gomock.Call
Method indicates an expected call of Method
func (*MockActionMockRecorder) TLS ¶
func (mr *MockActionMockRecorder) TLS() *gomock.Call
TLS indicates an expected call of TLS
func (*MockActionMockRecorder) URL ¶
func (mr *MockActionMockRecorder) URL(accessToken ...interface{}) *gomock.Call
URL indicates an expected call of URL
func (*MockActionMockRecorder) UploadForm ¶
func (mr *MockActionMockRecorder) UploadForm() *gomock.Call
UploadForm indicates an expected call of UploadForm
func (*MockActionMockRecorder) WXML ¶
func (mr *MockActionMockRecorder) WXML(appid, mchid, nonce interface{}) *gomock.Call
WXML indicates an expected call of WXML
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock of Client interface
func NewMockClient ¶
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance
func (*MockClient) EXPECT ¶
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockClient) Get ¶
func (m *MockClient) Get(ctx context.Context, reqURL string, options ...HTTPOption) ([]byte, error)
Get mocks base method
func (*MockClient) Post ¶
func (m *MockClient) Post(ctx context.Context, reqURL string, body []byte, options ...HTTPOption) ([]byte, error)
Post mocks base method
func (*MockClient) PostXML ¶
func (m *MockClient) PostXML(ctx context.Context, reqURL string, body WXML, options ...HTTPOption) (WXML, error)
PostXML mocks base method
func (*MockClient) Upload ¶
func (m *MockClient) Upload(ctx context.Context, reqURL string, form *UploadForm, options ...HTTPOption) ([]byte, error)
Upload mocks base method
type MockClientMockRecorder ¶
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
MockClientMockRecorder is the mock recorder for MockClient
func (*MockClientMockRecorder) Get ¶
func (mr *MockClientMockRecorder) Get(ctx, reqURL interface{}, options ...interface{}) *gomock.Call
Get indicates an expected call of Get
func (*MockClientMockRecorder) Post ¶
func (mr *MockClientMockRecorder) Post(ctx, reqURL, body interface{}, options ...interface{}) *gomock.Call
Post indicates an expected call of Post
func (*MockClientMockRecorder) PostXML ¶
func (mr *MockClientMockRecorder) PostXML(ctx, reqURL, body interface{}, options ...interface{}) *gomock.Call
PostXML indicates an expected call of PostXML
func (*MockClientMockRecorder) Upload ¶
func (mr *MockClientMockRecorder) Upload(ctx, reqURL, form interface{}, options ...interface{}) *gomock.Call
Upload indicates an expected call of Upload
type PaddingMode ¶
type PaddingMode string
PaddingMode aes padding mode
const ( // ZERO zero padding mode ZERO PaddingMode = "ZERO" // PKCS5 PKCS#5 padding mode PKCS5 PaddingMode = "PKCS#5" // PKCS7 PKCS#7 padding mode PKCS7 PaddingMode = "PKCS#7" )
type UploadForm ¶
type UploadForm struct {
// contains filtered or unexported fields
}
UploadForm http upload form
func NewUploadForm ¶
func NewUploadForm(fieldname, filename string, extraFields map[string]string) *UploadForm
NewUploadForm returns new uplod form
func (*UploadForm) Buffer ¶
func (f *UploadForm) Buffer() ([]byte, error)
func (*UploadForm) ExtraFields ¶
func (f *UploadForm) ExtraFields() map[string]string
func (*UploadForm) FieldName ¶
func (f *UploadForm) FieldName() string
func (*UploadForm) FileName ¶
func (f *UploadForm) FileName() string