wx

package
v0.0.0-...-2636f62 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: Apache-2.0 Imports: 19 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 Nonce

func Nonce(size uint) string

Nonce returns nonce string, param `size` better for even number.

Types

type Action

type Action interface {
	// URL returns request url
	URL(accessToken ...string) string

	// Method returns action method
	Method() ActionMethod

	// WXML returns body for xml request
	WXML(appid, mchid, nonce string) (WXML, error)

	// Body returns body for post request
	Body() ([]byte, error)

	// UploadForm returns form for uploading media
	UploadForm() (yiigo.UploadForm, error)

	// Decode decodes response
	Decode() func(resp []byte) error

	// TLS specifies the request with certificate
	TLS() bool
}

Action is the interface that handle wechat a

func NewAction

func NewAction(method ActionMethod, reqURL string, options ...ActionOption) Action

NewAction returns a new action

func NewGetAction

func NewGetAction(reqURL string, options ...ActionOption) Action

NewGetAction returns a new action with GET method

func NewPostAction

func NewPostAction(reqURL string, options ...ActionOption) Action

NewPostAction returns a new action with POST method

func NewUploadAction

func NewUploadAction(reqURL string, options ...ActionOption) Action

NewUploadAction returns a new action with UPLOAD method

type ActionMethod

type ActionMethod string

ActionMethod http request method

const (
	MethodGet    ActionMethod = "GET"
	MethodPost   ActionMethod = "POST"
	MethodUpload ActionMethod = "UPLOAD"
	MethodNone   ActionMethod = "NONE"
)

type ActionOption

type ActionOption func(a *action)

ActionOption configures how we set up the action

func WithBody

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

WithBody specifies the `body` to Action.

func WithDecode

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

WithDecode specifies the `decode` to Action.

func WithQuery

func WithQuery(key, value string) ActionOption

WithQuery specifies the `query` to Action.

func WithTLS

func WithTLS() ActionOption

WithTLS specifies the `tls` to Action.

func WithUploadField

func WithUploadField(field *UploadField) ActionOption

WithUploadField specifies the `upload field` to Action.

func WithWXML

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

WithWXML specifies the `wxml` to Action.

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 sends an HTTP get request
	Get(ctx context.Context, reqURL string, options ...yiigo.HTTPOption) ([]byte, error)

	// Post sends an HTTP post request
	Post(ctx context.Context, reqURL string, body []byte, options ...yiigo.HTTPOption) ([]byte, error)

	// PostXML sends an HTTP post request with xml
	PostXML(ctx context.Context, reqURL string, body WXML, options ...yiigo.HTTPOption) ([]byte, error)

	// Upload sends an HTTP post request for uploading media
	Upload(ctx context.Context, reqURL string, form yiigo.UploadForm, options ...yiigo.HTTPOption) ([]byte, error)
}

Client is the interface that do http request

func NewClient

func NewClient(options ...TLSOption) Client

NewClient returns a new http client

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 ...yiigo.HTTPOption) ([]byte, error)

Get mocks base method.

func (*MockClient) Post

func (m *MockClient) Post(ctx context.Context, reqURL string, body []byte, options ...yiigo.HTTPOption) ([]byte, error)

Post mocks base method.

func (*MockClient) PostXML

func (m *MockClient) PostXML(ctx context.Context, reqURL string, body WXML, options ...yiigo.HTTPOption) ([]byte, error)

PostXML mocks base method.

func (*MockClient) Upload

func (m *MockClient) Upload(ctx context.Context, reqURL string, form yiigo.UploadForm, options ...yiigo.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 TLSOption

type TLSOption func(cfg *tls.Config)

TLSOption configures how we set up the http client tls config

func WithInsecureSkipVerify

func WithInsecureSkipVerify() TLSOption

WithInsecureSkipVerify specifies the `InsecureSkipVerify` to http client tls config.

func WithTLSCertificates

func WithTLSCertificates(certs ...tls.Certificate) TLSOption

WithTLSCertificates specifies the certificate to http client tls config.

type UploadField

type UploadField struct {
	FileField string
	Filename  string
	MetaField string
	Metadata  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

Jump to

Keyboard shortcuts

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