wx

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package wx is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBytesToUint32

func DecodeBytesToUint32(b []byte) uint32

DecodeBytesToUint32 从 4 字节的网络字节序里解析出整数 uint32

func EncodeUint32ToBytes

func EncodeUint32ToBytes(i uint32) []byte

EncodeUint32ToBytes 把整数 uint32 格式化成 4 字节的网络字节序

func FormatMap2XML

func FormatMap2XML(m WXML) (string, error)

FormatMap2XML format map to xml

func MarshalWithNoEscapeHTML

func MarshalWithNoEscapeHTML(v interface{}) ([]byte, error)

MarshalWithNoEscapeHTML marshal with no escape HTML

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.

func PKCS5Padding

func PKCS5Padding(cipherText []byte, blockSize int) []byte

func PKCS5Unpadding

func PKCS5Unpadding(plainText []byte, blockSize int) []byte

func RSADecrypt

func RSADecrypt(cipherText, privateKey []byte) ([]byte, error)

RSADecrypt rsa decryption with private key

func RSAEncrypt

func RSAEncrypt(data, publicKey []byte) ([]byte, error)

RSAEncrypt rsa encryption with public key

func ZeroPadding

func ZeroPadding(cipherText []byte, blockSize int) []byte

func ZeroUnPadding

func ZeroUnPadding(plainText []byte) []byte

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API is a Action implementation

func (*API) Body

func (a *API) Body() ([]byte, error)

func (*API) Decode

func (a *API) Decode() func(resp []byte) error

func (*API) Method

func (a *API) Method() HTTPMethod

func (*API) TLS

func (a *API) TLS() bool

func (*API) URL

func (a *API) URL(accessToken ...string) string

func (*API) UploadForm

func (a *API) UploadForm() *UploadForm

func (*API) WXML

func (a *API) WXML(appid, mchid, nonce string) (WXML, error)

type APIOption

type APIOption func(api *API)

APIOption configures how we set up the wechat API

func WithBody

func WithBody(f func() ([]byte, error)) APIOption

WithBody specifies the `body` to API.

func WithDecode

func WithDecode(f func(resp []byte) error) APIOption

WithDecode specifies the `decode` to API.

func WithMethod

func WithMethod(method HTTPMethod) APIOption

WithMethod specifies the `method` to API.

func WithQuery

func WithQuery(key, value string) APIOption

WithQuery specifies the `query` to API.

func WithTLS

func WithTLS() APIOption

WithTLS specifies the `tls` to API.

func WithUploadForm

func WithUploadForm(fieldname, filename string, extraFields map[string]string) APIOption

WithUploadForm specifies the `upload form` to API.

func WithWXML

func WithWXML(f func(appid, mchid, nonce string) (WXML, error)) APIOption

WithWXML specifies the `wxml` 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

func NewAPI

func NewAPI(reqURL string, options ...APIOption) Action

NewAPI returns a new action

type CBCCrypto

type CBCCrypto struct {
	// contains filtered or unexported fields
}

CBCCrypto aes-cbc crypto

func NewCBCCrypto

func NewCBCCrypto(key, iv []byte) *CBCCrypto

NewCBCCrypto returns new aes-cbc crypto

func (*CBCCrypto) Decrypt

func (c *CBCCrypto) Decrypt(cipherText []byte, mode PaddingMode) ([]byte, error)

Decrypt aes-cbc decrypt

func (*CBCCrypto) Encrypt

func (c *CBCCrypto) Encrypt(plainText []byte, mode PaddingMode) ([]byte, error)

Encrypt aes-cbc encrypt

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

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

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

func NewECBCrypto(key []byte) *ECBCrypto

NewECBCrypto returns new aes-ecb crypto

func (*ECBCrypto) Decrypt

func (c *ECBCrypto) Decrypt(cipherText []byte, mode PaddingMode) ([]byte, error)

Decrypt aes-ecb decrypt

func (*ECBCrypto) Encrypt

func (c *ECBCrypto) Encrypt(plainText []byte, mode PaddingMode) ([]byte, error)

Encrypt aes-ecb encrypt

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) Body

func (m *MockAction) Body() ([]byte, error)

Body mocks base method

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) Method

func (m *MockAction) Method() HTTPMethod

Method mocks base method

func (*MockAction) TLS

func (m *MockAction) TLS() bool

TLS mocks base method

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

func (*MockAction) WXML

func (m *MockAction) WXML(appid, mchid, nonce string) (WXML, error)

WXML 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

type WXML

type WXML map[string]string

WXML deal with xml for wechat

func ParseXML2Map

func ParseXML2Map(b []byte) (WXML, error)

ParseXML2Map parse xml to map

type X

type X map[string]interface{}

X is a convenient alias for a map[string]interface{}.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL