Help us shape the future of Go! Take the 2026 Go Developer Survey

httpcall

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package httpcall is the outbound HTTP call both an Automation's HTTP step (ADR 0039) and a Rule's HTTP Action (ADR 0054) describe: a URL, request headers, a Liquid JSON body and an optional signing secret. It validates a call as written, seals its URL, header values and secret per field for storage, opens them for the executor and renders the body. It holds no client and no Workspace: the owner of the call decides when to make it (webhook.Post).

Index

Constants

View Source
const (
	MaxURLBytes  = 2 << 10
	MaxBodyBytes = 64 << 10
	MaxHeaders   = 5
)

Limits of a call (ADR 0039): they keep one call from exhausting the queue.

Variables

View Source
var ErrInvalidBody = errors.New("automations: body does not render to valid JSON")

ErrInvalidBody means the body did not render to valid JSON within the size limit.

Functions

func BodyDetail

func BodyDetail(err error) string

BodyDetail is the reason of a RenderBody error, without its prefix.

func RenderBody

func RenderBody(body string, bindings map[string]any) (string, error)

RenderBody renders a Liquid JSON body against bindings and checks the result is valid JSON within the size limit. The bindings' strings are JSON-escaped, so a value holding quotes cannot change the structure.

Types

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
}

Header is one request header. In a stored call Value is ciphertext. In a saved call, an empty Value keeps the stored value of the header with the same name.

type InvalidError

type InvalidError string

InvalidError is a call that does not fit the rules of a call. Its text is safe to show to the author.

func (InvalidError) Error

func (e InvalidError) Error() string

type Opened

type Opened struct {
	URL     string
	Headers map[string]string
	Secret  string
}

Opened is a call's secrets in the clear, for the executor.

func Open

func Open(c *secrets.Cipher, s Spec) (Opened, error)

Open decrypts a stored call's URL, header values and secret.

type Spec

type Spec struct {
	URL         string
	Headers     []Header
	Body        string
	Secret      string
	ClearSecret bool
}

Spec is a call. Stored, URL, header values and Secret are ciphertext; in a call being saved, an empty one keeps the stored value, and ClearSecret drops the signing secret.

func Seal

func Seal(c *secrets.Cipher, in, prev Spec, what string) (Spec, error)

Seal validates a call being saved and returns its stored form: URL, header values and secret encrypted per field. What the author did not resend (an empty URL, header value or secret) is copied, as stored ciphertext, from prev, the stored call it replaces (the zero Spec for a new one). what names the call in the errors ("http step", "http action"); a refusal is an InvalidError.

Jump to

Keyboard shortcuts

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