http

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout bounds a request when the step does not set `timeout`. The zero value of http.Client means "wait forever", which lets a single unresponsive endpoint hold a workflow open until the step timeout fires.

Variables

This section is empty.

Functions

func MarshalBodyIfJSON added in v1.18.0

func MarshalBodyIfJSON(data, m map[string]any)

MarshalBodyIfJSON converts body to JSON string when Content-Type is application/json Supports map[string]any and []any body types

func Request added in v1.18.0

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

func ResolveMethodAndURL added in v1.18.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

func Serve

func Serve()

Types

type Action

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

func (*Action) Run

func (a *Action) Run(with map[string]any) (map[string]any, error)

type Callback added in v1.18.0

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

type Option added in v1.18.0

type Option func(*Callback)

func WithAfter added in v1.18.0

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

func WithBefore added in v1.18.0

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

type Req added in v1.18.0

type Req struct {
	URL     string            `map:"url" validate:"required"`
	Method  string            `map:"method" validate:"required"`
	Header  map[string]string `map:"headers"`
	Body    string            `map:"body"` // Changed from []byte to string for text data
	Timeout string            `map:"timeout"`
	// contains filtered or unexported fields
}

func NewReq added in v1.18.0

func NewReq() *Req

func (*Req) Do added in v1.18.0

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

type Res added in v1.18.0

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 added in v1.18.0

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

Jump to

Keyboard shortcuts

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