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 Nonce(size uint) string
- type Action
- type ActionMethod
- type ActionOption
- func WithBody(f func() ([]byte, error)) ActionOption
- func WithDecode(f func(resp []byte) error) ActionOption
- func WithQuery(key, value string) ActionOption
- func WithTLS() ActionOption
- func WithUploadField(field *UploadField) ActionOption
- func WithWXML(f func(appid, mchid, nonce string) (WXML, error)) ActionOption
- type CDATA
- type Client
- type MockClient
- func (m *MockClient) EXPECT() *MockClientMockRecorder
- func (m *MockClient) Get(ctx context.Context, reqURL string, options ...yiigo.HTTPOption) ([]byte, error)
- func (m *MockClient) Post(ctx context.Context, reqURL string, body []byte, options ...yiigo.HTTPOption) ([]byte, error)
- func (m *MockClient) PostXML(ctx context.Context, reqURL string, body WXML, options ...yiigo.HTTPOption) ([]byte, error)
- func (m *MockClient) Upload(ctx context.Context, reqURL string, form yiigo.UploadForm, ...) ([]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 TLSOption
- type UploadField
- type WXML
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
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 WithUploadField ¶
func WithUploadField(field *UploadField) ActionOption
WithUploadField specifies the `upload field` 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 ¶
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
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 ¶
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.