util

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyEmptyStreamMessages = errors.New("stream has sent too many empty messages")
)

Functions

func HttpDelete

func HttpDelete(ctx context.Context, rawURL string, header map[string]string, data, result any, timeout time.Duration, proxyURL string, requestErrorHandler RequestErrorHandler) ([]byte, error)

func HttpDo

func HttpDo(ctx context.Context, method, rawURL string, header map[string]string, data, result any, timeout time.Duration, proxyURL string, requestErrorHandler RequestErrorHandler) ([]byte, error)

func HttpGet

func HttpGet(ctx context.Context, rawURL string, header map[string]string, data, result any, timeout time.Duration, proxyURL string, requestErrorHandler RequestErrorHandler) ([]byte, error)

func HttpPost

func HttpPost(ctx context.Context, rawURL string, header map[string]string, data, result any, timeout time.Duration, proxyURL string, requestErrorHandler RequestErrorHandler) ([]byte, error)

Types

type DefaultFormBuilder

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

func NewFormBuilder

func NewFormBuilder(body io.Writer) *DefaultFormBuilder

func (*DefaultFormBuilder) Close

func (fb *DefaultFormBuilder) Close() error

func (*DefaultFormBuilder) CreateFormFile

func (fb *DefaultFormBuilder) CreateFormFile(fieldname string, file *os.File) error

func (*DefaultFormBuilder) CreateFormFileHeader

func (fb *DefaultFormBuilder) CreateFormFileHeader(fieldname string, fileHeader *multipart.FileHeader) error

func (*DefaultFormBuilder) CreateFormFileReader

func (fb *DefaultFormBuilder) CreateFormFileReader(fieldname string, r io.Reader, filename string) error

func (*DefaultFormBuilder) FormDataContentType

func (fb *DefaultFormBuilder) FormDataContentType() string

func (*DefaultFormBuilder) WriteField

func (fb *DefaultFormBuilder) WriteField(fieldname, value string) error

type FormBuilder

type FormBuilder interface {
	CreateFormFile(fieldname string, file *os.File) error
	CreateFormFileHeader(fieldname string, fileHeader *multipart.FileHeader) error
	CreateFormFileReader(fieldname string, r io.Reader, filename string) error
	WriteField(fieldname, value string) error
	Close() error
	FormDataContentType() string
}

type RequestErrorHandler

type RequestErrorHandler func(ctx context.Context, response *http.Response) (err error)

type StreamReader

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

func SSEClient

func SSEClient(ctx context.Context, rawURL string, header map[string]string, data any, timeout time.Duration, proxyURL string, requestErrorHandler RequestErrorHandler) (stream *StreamReader, err error)

func (*StreamReader) Close

func (stream *StreamReader) Close() error

func (*StreamReader) Recv

func (stream *StreamReader) Recv() (response []byte, err error)

type WebSocketConn

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

func WebSocketClient

func WebSocketClient(ctx context.Context, wsURL string, requestHeader http.Header, messageType int, message []byte, proxyURL string) (*WebSocketConn, error)

func (*WebSocketConn) Close

func (c *WebSocketConn) Close() (err error)

func (*WebSocketConn) ReadMessage

func (c *WebSocketConn) ReadMessage(ctx context.Context) (int, []byte, error)

func (*WebSocketConn) WriteJSON

func (c *WebSocketConn) WriteJSON(ctx context.Context, message any) error

func (*WebSocketConn) WriteMessage

func (c *WebSocketConn) WriteMessage(ctx context.Context, messageType int, message []byte) error

Jump to

Keyboard shortcuts

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