httpclient

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Code generated by MockGen. DO NOT EDIT. Source: github.com/devinyf/dashscopego/httpclient (interfaces: IHttpClient)

Generated by this command:

mockgen -destination=http_client_mock.go -package=httpclient . IHttpClient

Package httpclient is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrNetwork = errors.New("network error")

Functions

func NetworkStatus

func NetworkStatus() (bool, error)

Types

type EmptyRequestBodyError

type EmptyRequestBodyError struct {
	Method string
}

func (*EmptyRequestBodyError) Error

func (e *EmptyRequestBodyError) Error() string

type HTTPCli

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

func NewHTTPClient

func NewHTTPClient() *HTTPCli

func (*HTTPCli) EncodeJSONBody

func (c *HTTPCli) EncodeJSONBody(body interface{}) (*bytes.Buffer, error)

func (*HTTPCli) Get

func (c *HTTPCli) Get(ctx context.Context, urll string, params map[string]string, respbody interface{}, options ...HTTPOption) error

func (*HTTPCli) GetImage

func (c *HTTPCli) GetImage(ctx context.Context, imgURL string, options ...HTTPOption) ([]byte, error)

func (*HTTPCli) Post

func (c *HTTPCli) Post(ctx context.Context, urll string, reqbody interface{}, respbody interface{}, options ...HTTPOption) error

nolint:lll

func (*HTTPCli) PostSSE

func (c *HTTPCli) PostSSE(ctx context.Context, urll string, reqbody interface{}, options ...HTTPOption) (chan string, error)

nolint:lll

type HTTPOption

type HTTPOption func(c *HTTPCli)

func WithHeader

func WithHeader(header HeaderMap) HTTPOption

func WithStream

func WithStream() HTTPOption

func WithTimeout

func WithTimeout(timeout time.Duration) HTTPOption

func WithTokenHeaderOption

func WithTokenHeaderOption(token string) HTTPOption

type HTTPRequestError

type HTTPRequestError struct {
	Message string
	Cause   error
	Code    int
}

func (*HTTPRequestError) Error

func (e *HTTPRequestError) Error() string

type HeaderMap

type HeaderMap map[string]string

type IHttpClient

type IHttpClient interface {
	PostSSE(ctx context.Context, urll string, reqbody interface{}, options ...HTTPOption) (chan string, error)
	Post(ctx context.Context, urll string, reqbody interface{}, resp interface{}, options ...HTTPOption) error
	Get(ctx context.Context, urll string, params map[string]string, resp interface{}, options ...HTTPOption) error
	GetImage(ctx context.Context, imgURL string, options ...HTTPOption) ([]byte, error)
}

type IWsClient

type IWsClient interface {
	ConnClient(req interface{}) error
	CloseClient() error
	SendBinaryDates(data []byte)
	ResultChans(wsmsg <-chan WsMessage, err <-chan error)
}

type MockIHttpClient

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

MockIHttpClient is a mock of IHttpClient interface.

func NewMockIHttpClient

func NewMockIHttpClient(ctrl *gomock.Controller) *MockIHttpClient

NewMockIHttpClient creates a new mock instance.

func (*MockIHttpClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIHttpClient) Get

func (m *MockIHttpClient) Get(arg0 context.Context, arg1 string, arg2 map[string]string, arg3 any, arg4 ...HTTPOption) error

Get mocks base method.

func (*MockIHttpClient) GetImage

func (m *MockIHttpClient) GetImage(arg0 context.Context, arg1 string, arg2 ...HTTPOption) ([]byte, error)

GetImage mocks base method.

func (*MockIHttpClient) Post

func (m *MockIHttpClient) Post(arg0 context.Context, arg1 string, arg2, arg3 any, arg4 ...HTTPOption) error

Post mocks base method.

func (*MockIHttpClient) PostSSE

func (m *MockIHttpClient) PostSSE(arg0 context.Context, arg1 string, arg2 any, arg3 ...HTTPOption) (chan string, error)

PostSSE mocks base method.

type MockIHttpClientMockRecorder

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

MockIHttpClientMockRecorder is the mock recorder for MockIHttpClient.

func (*MockIHttpClientMockRecorder) Get

func (mr *MockIHttpClientMockRecorder) Get(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call

Get indicates an expected call of Get.

func (*MockIHttpClientMockRecorder) GetImage

func (mr *MockIHttpClientMockRecorder) GetImage(arg0, arg1 any, arg2 ...any) *gomock.Call

GetImage indicates an expected call of GetImage.

func (*MockIHttpClientMockRecorder) Post

func (mr *MockIHttpClientMockRecorder) Post(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call

Post indicates an expected call of Post.

func (*MockIHttpClientMockRecorder) PostSSE

func (mr *MockIHttpClientMockRecorder) PostSSE(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call

PostSSE indicates an expected call of PostSSE.

type WrapMessageError

type WrapMessageError struct {
	Message string
	Cause   error
}

func (*WrapMessageError) Error

func (e *WrapMessageError) Error() string

type WsClient

type WsClient struct {
	URL     string
	Headers http.Header
	Conn    *websocket.Conn
	// contains filtered or unexported fields
}

Client represents a websocket client.

func NewWsClient

func NewWsClient(url string, headers http.Header) *WsClient

func (*WsClient) CloseClient

func (c *WsClient) CloseClient() error

func (*WsClient) ConnClient

func (c *WsClient) ConnClient(req interface{}) error

StartClient starts the client operation.

func (*WsClient) ResultChans

func (c *WsClient) ResultChans() (<-chan WsMessage, <-chan error)

func (*WsClient) SendBinaryDates

func (c *WsClient) SendBinaryDates(data []byte)

type WsMessage

type WsMessage struct {
	// ws data type, e.g. websocket.TextMessage, websocket.BinaryMessage...
	Type int
	// ws data body
	Data []byte
}

Jump to

Keyboard shortcuts

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