outgoing

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMethodEmpty = errors.New("method is empty")
	ErrURLEmpty    = errors.New("url is empty")
)

Functions

func Invoke added in v0.2.0

func Invoke(ctx context.Context, middleware Middleware, cli *http.Client, request *http.Request) (*http.Response, error)

Types

type FormData

type FormData struct {
	FieldName string
	Value     string
	File      io.Reader
	Filename  string
}

type Invoker

type Invoker func(ctx context.Context, req *http.Request, cli *http.Client) (*http.Response, error)

type MarshalError

type MarshalError struct {
	Err error
	// contains filtered or unexported fields
}

func (MarshalError) Body added in v0.2.0

func (e MarshalError) Body() any

func (MarshalError) Error

func (e MarshalError) Error() string

func (MarshalError) Unwrap added in v0.2.0

func (e MarshalError) Unwrap() error

type MethodSender added in v0.2.0

type MethodSender interface {
	Method(method string) URLSender
	Get() URLSender
	Head() URLSender
	Post() URLSender
	Put() URLSender
	Patch() URLSender
	Delete() URLSender
	Connect() URLSender
	Options() URLSender
	Trace() URLSender
}

func Sender

func Sender() MethodSender

Sender returns a new RequestSender.

type Middleware

type Middleware func(ctx context.Context, req *http.Request, cli *http.Client, invoker Invoker) (*http.Response, error)

type PayloadSender

type PayloadSender interface {

	// other methods
	Middleware(middlewares ...Middleware) PayloadSender
	Build(ctx context.Context) (*http.Request, error)
	Send(ctx context.Context, cli ...*http.Client) (Receiver, error)
	// contains filtered or unexported methods
}

type Receiver

type Receiver interface {
	Response() *http.Response
	Status() string
	StatusCode() int
	Proto() string
	ProtoMajor() int
	ProtoMinor() int
	ContentLength() int64
	TransferEncoding() []string
	Headers() http.Header
	Trailers() http.Header
	Cookies() []*http.Cookie
	BytesBody() ([]byte, error)
	TextBody() (string, error)
	ObjectBody(body any, unmarshal func([]byte, any) error) error
	JSONBody(body any) error
	XMLBody(body any) error
	ProtobufBody(body proto.Message) error
	GobBody(body any) error
	WriterBody(file io.Writer) error
}

type URLSender

type URLSender interface {
	URL(uri *url.URL) PayloadSender
	URLString(urlString string) PayloadSender
}

func Connect

func Connect() URLSender

Connect returns a new RequestSender with the method CONNECT.

func Delete

func Delete() URLSender

Delete returns a new RequestSender with the method DELETE.

func Get

func Get() URLSender

Get returns a new RequestSender with the method GET.

func Head() URLSender

Head returns a new RequestSender with the method HEAD.

func Method

func Method(method string) URLSender

Method returns a new RequestSender with the specified method.

func Options

func Options() URLSender

Options returns a new RequestSender with the method OPTIONS.

func Patch

func Patch() URLSender

Patch returns a new RequestSender with the method PATCH.

func Post

func Post() URLSender

Post returns a new RequestSender with the method POST.

func Put

func Put() URLSender

Put returns a new RequestSender with the method PUT.

func Trace

func Trace() URLSender

Trace returns a new RequestSender with the method TRACE.

type UnmarshalError

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

func (UnmarshalError) Body

func (e UnmarshalError) Body() []byte

func (UnmarshalError) Error

func (e UnmarshalError) Error() string

func (UnmarshalError) Unwrap added in v0.2.0

func (e UnmarshalError) Unwrap() error

Jump to

Keyboard shortcuts

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