http

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBodyToFormEncoded added in v0.20.0

func ConvertBodyToFormEncoded(data map[string]string) error

ConvertBodyToFormEncoded converts body__ prefixed fields to form-encoded body

func PrepareRequestData added in v0.20.0

func PrepareRequestData(data map[string]string) error

PrepareRequestData prepares all request data including method fields and body conversion

func Request

func Request(data map[string]string, opts ...Option) (map[string]string, error)

func ResolveMethodAndURL added in v0.20.0

func ResolveMethodAndURL(data map[string]string) error

ResolveMethodAndURL resolves HTTP method fields and updates the data map Converts method fields like "get", "post" to "method" and "url" fields

Types

type Callback

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

type Option

type Option func(*Callback)

func WithAfter

func WithAfter(f func(res *hp.Response)) Option

func WithBefore

func WithBefore(f func(req *hp.Request)) Option

type Req

type Req struct {
	URL    string            `map:"url" validate:"required"`
	Method string            `map:"method" validate:"required"`
	Proto  string            `map:"ver"`
	Header map[string]string `map:"headers"`
	Body   []byte            `map:"body"`
	// contains filtered or unexported fields
}

func NewReq

func NewReq() *Req

func (*Req) Do

func (r *Req) Do() (*Result, error)

type Res

type Res struct {
	Status string            `map:"status"`
	Code   int               `map:"code"`
	Header map[string]string `map:"headers"`
	Body   []byte            `map:"body"`
}

type Result

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
}

type TransportOptions

type TransportOptions struct {
	Timeout      int `map:"timeout"`
	MaxIdleConns int `map:"max_idle_conns"`
}

Jump to

Keyboard shortcuts

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