request

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormRequest

func FormRequest(requestUrl, method string, data map[string]string, opts ...Option) ([]byte, int, error)

FormRequest form-data请求

func JsonRequest

func JsonRequest(requestUrl, method string, data map[string]interface{}, opts ...Option) ([]byte, int, error)

JsonRequest json请求

func Request

func Request(requestUrl, method string, body io.Reader, opts ...Option) ([]byte, int, error)

Request http请求

func StreamRequest

func StreamRequest(requestUrl, method string, body io.Reader, fn func([]byte) error, opts ...Option) (int, error)

StreamRequest 流式请求

Types

type Flusher

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

Flusher is a wrapper for http.ResponseWriter with Flush method.

func NewFlusher

func NewFlusher(writer http.ResponseWriter, httpFlusher http.Flusher) *Flusher

func (*Flusher) Flush

func (f *Flusher) Flush()

func (*Flusher) Writer

func (f *Flusher) Writer(body string) (int, error)

func (*Flusher) WriterWithFlush

func (f *Flusher) WriterWithFlush(body string) (n int, err error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置请求上下文

func WithHeader

func WithHeader(key, value string) Option

WithHeader 设置请求头

func WithStreamMaxBufferSize

func WithStreamMaxBufferSize(maxBufferSize int) Option

WithStreamMaxBufferSize 设置流式请求最大缓存大小

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 设置请求超时时间

func WithTraceContext

func WithTraceContext(ctx context.Context) Option

WithTraceContext 从context中自动提取trace信息

func WithTracer

func WithTracer(traceIdKey, spanIdKey string) Option

WithTracer 添加链路追踪

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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