http

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 38 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.

View Source
const DefaultTraceHeader = "X-Probe-Trace"

DefaultTraceHeader is the header trace_header: true sends.

Variables

This section is empty.

Functions

func Keeps

func Keeps() []string

Keeps returns the kinds of guard the http action keeps to: it sends only GET, HEAD and OPTIONS under read-only, and connects only to a host the guard allows, redirects included.

func MarshalBodyIfJSON

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 Params

func Params() []string

Params returns the keys the http action takes in with: those of Req, the method shorthands, such as get and post, and those it reads apart from Req.

func Request

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

func RequestStep

func RequestStep(call actionrpc.Call, opts ...Option) (map[string]any, map[string]any, error)

RequestStep is Request for a step, with the state the action keeps in a job. When keep_cookies is true, the cookies kept in the state are sent, and the state returned keeps those the server set as well; otherwise the state returned is nil, which leaves the job's state as it was. When trace_header is given, the request carries a header that names the run, job and step.

func ResolveMethodAndURL

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)

func (*Action) RunStep

func (a *Action) RunStep(call actionrpc.Call) (map[string]any, map[string]any, error)

RunStep runs the request for a step: with the cookies the job keeps, when the step asks for keep_cookies, returning the cookies to keep, and with a header that names the step, when it asks for trace_header.

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"`
	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

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
	// Cookies holds the names and values of the cookies the server set, on
	// redirects included.
	Cookies map[string]string `map:"cookies"`
}

type Result

type Result struct {
	Req    Req           `map:"req"`
	Res    Res           `map:"res"`
	RT     time.Duration `map:"rt"`
	Status int           `map:"status"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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