http

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Request

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

func ResolveMethodAndURL added in v0.20.0

func ResolveMethodAndURL(data map[string]any) 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   string            `map:"body"` // Changed from []byte to string for text data
	// 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     string            `map:"body"`     // Changed from []byte to string for text data
	FilePath string            `map:"filepath"` // New field for binary file paths
}

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